diff options
Diffstat (limited to 'Src/init.c')
-rw-r--r-- | Src/init.c | 12 |
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, * |