]> Zhao Yanbai Git Server - minix.git/commitdiff
libutil: add O_NOCTTY to old pty open code
authorBen Gras <ben@minix3.org>
Mon, 26 Mar 2012 15:00:45 +0000 (17:00 +0200)
committerBen Gras <ben@minix3.org>
Tue, 27 Mar 2012 00:39:57 +0000 (02:39 +0200)
. fixes e.g. ssh sessions not getting their own
  controlling tty (causing ^C getting broadcast to too
  many processes)
. previously (before -lutil) handled like this by bsd-openpty.c in
  openssh
. reported by Andy Kosela, debugged by ThomasV

lib/libutil/pty.c

index 6a0e0c304b566ef3245353a9c4c59ea2d00ff987..dc1bee630e5a6df5d147b7677ffce4547903ac16 100644 (file)
@@ -105,7 +105,7 @@ openpty(int *amaster, int *aslave, char *name, struct termios *term,
                for (cp = cp2 = TTY_OLD_SUFFIX TTY_NEW_SUFFIX; *cp2; cp2++) {
                        line[5] = 'p';
                        line[9] = *cp2;
-                       if ((master = open(line, O_RDWR, 0)) == -1) {
+                       if ((master = open(line, O_RDWR | O_NOCTTY, 0)) == -1) {
                                if (errno != ENOENT)
                                        continue;       /* busy */
                                if ((size_t)(cp2 - cp + 1) < sizeof(TTY_OLD_SUFFIX))
@@ -120,7 +120,7 @@ openpty(int *amaster, int *aslave, char *name, struct termios *term,
 #ifndef __minix
                            revoke(line) == 0 &&
 #endif
-                           (slave = open(line, O_RDWR, 0)) != -1) {
+                           (slave = open(line, O_RDWR | O_NOCTTY, 0)) != -1) {
 #ifndef __minix
 gotit:
 #endif