[PATCH] luit: Cygwin compatibility fix

Yaakov (Cygwin/X) yselkowitz at users.sourceforge.net
Tue Oct 6 10:52:07 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..cc79645 100644
--- a/sys.c
+++ b/sys.c
@@ -408,7 +408,17 @@ openTty(char *line)
     int rc;
     int tty = -1;
+#if defined(__CYGWIN__) && !defined(TIOCSCTTY)
+    /* Cygwin currently) has O_NOCTTY but not TIOCSCTTY, so the tty
+       never becomes controlling */
+    tty = open(line, O_RDWR);
+    /* 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);
     if(tty < 0)
         goto bail;

More information about the xorg-devel mailing list