diff options
author | Yaakov Selkowitz <yselkowitz@users.sourceforge.net> | 2009-10-06 13:28:58 -0500 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2009-10-06 22:24:57 +0100 |
commit | 6de92b1ddf17a16a8075ad3922da68e72dcc949f (patch) | |
tree | d9adac6cdacfe60b7b51e3f1ce3e29d638e1d99a | |
parent | f5e4bc812cec6503722ee289a0cc1099ce6fb3f5 (diff) |
luit: Cygwin compatibility fix
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@users.sourceforge.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@sun.com>
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rw-r--r-- | sys.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -408,8 +408,18 @@ 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 + must be opened as 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; |