[PATCH] luit: Cygwin compatibility fix

Yaakov (Cygwin/X) yselkowitz at users.sourceforge.net
Tue Oct 6 11:28:58 PDT 2009


From: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>

Cygwin has O_NOCTTY but not TIOCSCTTY, so there is no way for the tty
to become controlling this way.  Also, document the reason for calling
one right after the other.

Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
---
 sys.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/sys.c b/sys.c
index ba60fbf..cd8712e 100644
--- a/sys.c
+++ b/sys.c
@@ -408,7 +408,17 @@ openTty(char *line)
     int rc;
     int tty = -1;
 
+#if !defined(O_NOCTTY) || !defined(TIOCSCTTY)
+    /* e.g. Cygwin has a working O_NOCTTY but no TIOCSCTTY, so the tty
+       never becomes controlling */
+    tty = open(line, O_RDWR);
+#else
+    /* The TIOCSCTTY ioctl below will fail if the process already has a
+       controlling tty (even if the current controlling tty is the same
+       as the tty you want to make controlling).  So we need to open
+       the tty with O_NOCTTY to make sure this doesn't happen. */
     tty = open(line, O_RDWR | O_NOCTTY);
+#endif
  
     if(tty < 0)
         goto bail;
-- 
1.6.4.2



More information about the xorg-devel mailing list