OSDN Git Service

* syscalls.cc (open): Add temporary kludge to avoid assigning the controlling
authorcgf <cgf>
Mon, 10 Oct 2011 22:01:03 +0000 (22:01 +0000)
committercgf <cgf>
Mon, 10 Oct 2011 22:01:03 +0000 (22:01 +0000)
tty on open unless the open is for stdin/stdout/stderr.
* tty.cc (tty_list::connect): Set ENXIO when can't find a tty.

winsup/cygwin/ChangeLog
winsup/cygwin/syscalls.cc
winsup/cygwin/tty.cc

index 0abec83..0d1e187 100644 (file)
@@ -1,3 +1,9 @@
+2011-10-10  Christopher Faylor  <me.cygwin2011@cgf.cx>
+
+       * syscalls.cc (open): Add temporary kludge to avoid assigning the
+       controlling tty on open unless the open is for stdin/stdout/stderr.
+       * tty.cc (tty_list::connect): Set ENXIO when can't find a tty.
+
 2011-10-10  Corinna Vinschen  <corinna@vinschen.de>
 
        * fhandler.h (fhandler_process::closedir): Declare.
index 54d75d0..1628254 100644 (file)
@@ -1130,6 +1130,12 @@ open (const char *unix_path, int flags, ...)
 
       if (fd >= 0)
        {
+         /* This is a temporary kludge until all utilities can catch up with
+            a change in behavior that implements linux functionality:  opening
+            a tty should not automatically cause it to become the controlling
+            tty for the process.  */
+         if (fd > 2)
+           flags |= O_NOCTTY;
          if (!(fh = build_fh_name (unix_path,
                                    (flags & (O_NOFOLLOW | O_EXCL))
                                    ?  PC_SYM_NOFOLLOW : PC_SYM_FOLLOW,
index e751d30..30879b0 100644 (file)
@@ -103,6 +103,7 @@ tty_list::connect (int ttynum)
   if (!ttys[ttynum].exists ())
     {
       termios_printf ("tty %d was not allocated", ttynum);
+      set_errno (ENXIO);
       return -1;
     }