summary refs log tree commit diff
path: root/Src/init.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-07-12 15:09:56 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-07-12 15:09:56 +0000
commit3257f6b8d561cdf8805744d2a988b4bf414249fc (patch)
tree0fd39eb26cadc23d17368c91217067816745c331 /Src/init.c
parent653d6a0dd95668eb3ad0d92de985cf14c1f65a8d (diff)
downloadzsh-3257f6b8d561cdf8805744d2a988b4bf414249fc.tar.gz
zsh-3257f6b8d561cdf8805744d2a988b4bf414249fc.tar.xz
zsh-3257f6b8d561cdf8805744d2a988b4bf414249fc.zip
27134: Close SHTTY on exec.
27135: POSIX_JOBS leaves MONITOR on in subshell and doesn't save
parent job table.
Diffstat (limited to 'Src/init.c')
-rw-r--r--Src/init.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Src/init.c b/Src/init.c
index b807f0659..be1055a53 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -480,8 +480,16 @@ init_io(void)
     if (SHTTY == -1) {
 	zsfree(ttystrname);
 	ttystrname = ztrdup("");
-    } else if (!ttystrname) {
-	ttystrname = ztrdup("/dev/tty");
+    } else {
+#ifdef FD_CLOEXEC
+	long fdflags = fcntl(SHTTY, F_GETFD, 0);
+	if (fdflags != (long)-1) {
+	    fdflags |= FD_CLOEXEC;
+	    fcntl(SHTTY, F_SETFD, fdflags);
+	}
+#endif
+	if (!ttystrname)
+	    ttystrname = ztrdup("/dev/tty");
     }
 
     /* We will only use zle if shell is interactive, *