If you are using serial console simply to print console messages then do not run a getty process on the serial port.
getty follows a locking convention that prevents other serial port applications from using the serial port. Since we do not want other processes to use the serial port, but are not running getty, manually create the lock file.
Create a file /var/lock/LCK..ttyS0 to contain the text 1. This lets other potential serial port applications know that process 1 has the serial port in use. Process 1 is always the init process, and init is always running, so the serial port is always locked.
The file is created upon each system boot, as lock files are often cleared when the system boots. A convenient place to create the lock file is from /etc/rc.serial. It should contain:
Figure 6-10. Contents of /etc/rc.serial to lock console serial port when no getty used
# Lock /dev/ttyS0 as it is used by an output-only console (umask 022 && \ rm -f '/var/lock/LCK..ttyS0' && \ echo '1' > '/var/lock/LCK..ttyS0')