If the vt gets a vhangup from under us, then the tty will appear ready
in select(), but trying to tcflush() it will return -EIO, so we'll spin
around at 100% CPU for no reason.  Notice this condition and unregister
the handler if it happens.

Signed-off-by: Adam Jackson <[email protected]>
---
 hw/xfree86/os-support/linux/lnx_init.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/hw/xfree86/os-support/linux/lnx_init.c 
b/hw/xfree86/os-support/linux/lnx_init.c
index c8cec2e..21f2220 100644
--- a/hw/xfree86/os-support/linux/lnx_init.c
+++ b/hw/xfree86/os-support/linux/lnx_init.c
@@ -85,7 +85,11 @@ static void *console_handler;
 static void
 drain_console(int fd, void *closure)
 {
-    tcflush(fd, TCIOFLUSH);
+    errno = 0;
+    if (tcflush(fd, TCIOFLUSH) == -1 && errno == EIO) {
+       xf86RemoveGeneralHandler(console_handler);
+       console_handler = NULL;
+    }
 }
 
 void
-- 
1.7.2.1

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to