misc/110017: serial port console output garbled (patch)

dan at more.net dan at more.net
Tue Mar 6 23:20:05 UTC 2007

>Number:         110017
>Category:       misc
>Synopsis:       serial port console output garbled (patch)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 06 23:20:04 GMT 2007
>Originator:     Dan D Niles
>Release:        FreeBSD 6.2-RELEASE-p2 i386
MOREnet - Missouri Research and Education Network
System: FreeBSD server.net 6.2-RELEASE-p2 FreeBSD 6.2-RELEASE-p2 #0: Tue Feb 27 22:56:09 UTC 2007 root at i386-builder.daemonology.net:/usr/obj/usr/src/sys/SMP i386

Dell 2950 with console redirection on, ttyd0 enabled in /etc/ttys.
	When using a serial port for a console, entering a blank line,
a line that starts with a '-', or a line containing only spaces causes
the output to become garbled.  This can result in loss of console output
when you are using a console server that stores console output (such
as the Cyclades AlterPath console servers).

The problem has been there for a while, but is more pronounced on a
Dell 1950 or 2950.
	On a Dell 2950, enable console redirection and set up ttyd0
in /etc/ttys.
	Connect to the serial port.
	Hit Enter.
	The output will look something like:



	Inserting a sleep(1) before the setttymode(0) inside the
main for loop fixes the problem.  I'm not sure _why_ it works,
but I don't think it is unreasonable to have a small delay after
entering invalid input.

Here are two potential patches.  The first one is the simplest.
The second one can be used instead if a 1 sec delay is undesireable 
when AB or PS are set.  The output might get garbled when AB or
PS are set, I did not test that.  If they do, the second patch
would not work.

--- libexec/getty/main.c.orig	Tue Mar  6 15:55:35 2007
+++ libexec/getty/main.c	Tue Mar  6 15:58:06 2007
@@ -295,6 +295,8 @@
 		    /* remove any noise */
 		    (void)tcflush(STDIN_FILENO, TCIOFLUSH);
+		if (!first_sleep)
+		    sleep(1);
 		first_sleep = 0;
@@ -376,6 +378,7 @@
 			if (name[0] == '-') {
 				puts("user names may not start with '-'.");
+				oflush();
 			if (!(upper || lower || digit)) {

And the alternate patch:

--- libexec/getty/main.c.orig	Tue Mar  6 15:55:35 2007
+++ libexec/getty/main.c.alt	Tue Mar  6 16:06:50 2007
@@ -372,10 +372,14 @@
 			signal(SIGALRM, SIG_DFL);
-			if (name[0] == '\0')
+			if (name[0] == '\0'){
+				sleep(1);
+			}
 			if (name[0] == '-') {
 				puts("user names may not start with '-'.");
+				oflush();
+				sleep(1);
 			if (!(upper || lower || digit)) {
@@ -384,6 +388,7 @@
 					    "invalid auto-login name: %s", AL);
 				} else
+					sleep(1);

More information about the freebsd-bugs mailing list