Subject: port-i386/4321: pccons can leave junk in tty input queue after X exits
To: None <gnats-bugs@gnats.netbsd.org>
From: None <cgd@NetBSD.ORG>
List: netbsd-bugs
Date: 10/23/1997 01:01:06
>Number: 4321
>Category: port-i386
>Synopsis: pccons can leave junk in tty input queue after X exits
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: gnats-admin (GNATS administrator)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Oct 22 18:05:01 1997
>Last-Modified:
>Originator: Chris G. Demetriou
>Organization:
Kernel Hackers 'r' Us
>Release: NetBSD-current (1.3ALPHA) as of October 22, 1997
>Environment:
System: NetBSD brick.demetriou.com 1.2G NetBSD 1.2G (BRICK) #1: Sat Oct 18 18:08:21 PDT 1997 cgd@brick.demetriou.com:/a/users/cgd/netbsd-src/src.pcmcia/sys/arch/i386/compile/BRICK i386
(but with an updated kernel being used for testing.)
>Description:
The i386 pccons driver can and often does leave "junk" in
the tty input queue when brought out of X mode.
This "junk" is actually event-mode ("X mode") keyboard data,
which wasn't processed by the server but which was left in
the queue when the tty was switched back to 'normal' mode.
>How-To-Repeat:
log in on a pccons console, with csh as your shell. xinit.
control-alt-backspace to exit the server. hit return. notice
the garbage that showed up as input to the shell.
>Fix:
Arguably, the correct fix is to avoid using the same device
for tty input as you do for X keyboard input. However, the
following patch works around the problem.
Arguably the X server should do this, as well, but it doesn't
hurt for the driver to do it.
Index: pccons.c
===================================================================
RCS file: /cvsroot/src/sys/arch/i386/isa/pccons.c,v
retrieving revision 1.113
diff -c -r1.113 pccons.c
*** pccons.c 1997/10/09 02:05:01 1.113
--- pccons.c 1997/10/23 00:58:41
***************
*** 49,54 ****
--- 49,55 ----
#include <sys/user.h>
#include <sys/select.h>
#include <sys/tty.h>
+ #include <sys/fcntl.h>
#include <sys/uio.h>
#include <sys/callout.h>
#include <sys/systm.h>
***************
*** 698,706 ****
--- 699,709 ----
#ifdef XSERVER
case CONSOLE_X_MODE_ON:
pc_xmode_on();
+ ttyflush(tp, FREAD);
return 0;
case CONSOLE_X_MODE_OFF:
pc_xmode_off();
+ ttyflush(tp, FREAD);
return 0;
case CONSOLE_X_BELL:
/*
>Audit-Trail:
>Unformatted: