]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Use O_NOCTTY (if available) when opening /dev/ptmx, just in case any
authorSimon Tatham <anakin@pobox.com>
Tue, 18 Dec 2012 09:02:38 +0000 (09:02 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 18 Dec 2012 09:02:38 +0000 (09:02 +0000)
OS doesn't automatically assume it.

(It would seem faintly weird to me - surely opening the master end of
a given pty is a fairly good indication that you're _not_ a process
running inside it which wants to have it available as /dev/tty! But
you never know...)

[originally from svn r9727]

unix/uxpty.c

index 36a05fccc373d4511d1e48bb43bd2cfdf4801d04..99c1221afe5f123d46b30fa63104d84c388daac8 100644 (file)
@@ -335,7 +335,14 @@ static void pty_open_master(Pty pty)
     chown(pty->name, getuid(), gp ? gp->gr_gid : -1);
     chmod(pty->name, 0600);
 #else
-    pty->master_fd = open("/dev/ptmx", O_RDWR);
+
+    const int flags = O_RDWR
+#ifdef O_NOCTTY
+        | O_NOCTTY
+#endif
+        ;
+
+    pty->master_fd = open("/dev/ptmx", flags);
 
     if (pty->master_fd < 0) {
        perror("/dev/ptmx: open");