summaryrefslogtreecommitdiff
path: root/packages/nonworking/xfree86/xfree86-4.3.0/tinyx-kbd-enable-fix.patch
blob: 2c5355c9e44005527f60f207bbe6e91316e5eae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--- xc/programs/Xserver/hw/kdrive/linux/keyboard.c.orig	2001-11-08 10:26:24.000000000 +0000
+++ xc/programs/Xserver/hw/kdrive/linux/keyboard.c	2003-03-11 21:13:09.000000000 +0000
@@ -397,12 +397,13 @@
 static struct termios	LinuxTermios;
 static int		LinuxKbdType;
 
-void
+int
 LinuxKeyboardEnable (int fd, void *closure)
 {
     struct termios nTty;
     unsigned char   buf[256];
     int		    n;
+    int             fd_orig_flags;
 
     ioctl (fd, KDGKBMODE, &LinuxKbdTrans);
     tcgetattr (fd, &LinuxTermios);
@@ -420,9 +421,18 @@
     tcsetattr(fd, TCSANOW, &nTty);
     /*
      * Flush any pending keystrokes
+     *
+     * Also set to nonblock, just to be safe
      */
+    fd_orig_flags  =  fcntl( fd , F_GETFL, 0 );
+    fcntl ( fd, F_SETFL, fd_orig_flags | O_NONBLOCK );
+
     while ((n = read (fd, buf, sizeof (buf))) > 0)
-	;
+    	;
+
+    fcntl ( fd ,  F_SETFL, fd_orig_flags );
+
+    return fd;
 }
 
 void