[Pkg-kbd-devel] Bug#190385: Fix

Jim Paris jim at jtan.com
Wed May 23 08:49:55 UTC 2007


tags 190385 +patch
thanks

Hi,

I can't reproduce this exactly, but looking at the trace:

31443 open("/dev/tty", O_RDONLY)        = 3
31443 ioctl(3, 0x4b33, 0xbffff8eb)      = -1 EINVAL (Invalid argument)
31443 open("/dev/console", O_RDONLY)    = 4
31443 ioctl(4, 0x4b33, 0xbffff8eb)      = -1 EINVAL (Invalid argument)
31443 ioctl(0, 0x4b33, 0xbffff91b)      = 0

It's trying to find a console device, and neither "/dev/tty" nor
"/dev/console" work, so the code falls back to checking the existing
fds 0, 1, 2.  In this case your stdin (/dev/tty1) is an actual console
device, and so it uses that.

However, once it's later finished with this fd, it closes it, which
actually closes stdin:

31444 open("/dev/tty30", O_RDWR)        = 0
31444 close(1)                          = 0
31444 close(2)                          = 0
31444 close(0)                          = 0

It really should only close the device if it opened it, not if it had
fallen back to re-using 0 1 or 2 in order to find the console device.

The appended patch should fix it.

-jim

diff -urN kbd-1.12.orig/openvt/openvt.c kbd-1.12/openvt/openvt.c
--- kbd-1.12.orig/openvt/openvt.c	2004-01-03 11:05:17.000000000 -0500
+++ kbd-1.12/openvt/openvt.c	2007-05-23 04:42:34.000000000 -0400
@@ -255,7 +255,8 @@
       }
       close(1);
       close(2);
-      close(consfd);
+      if (consfd > 2)
+	      close(consfd);
       dup(fd);
       dup(fd);
 




More information about the Pkg-kbd-devel mailing list