summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c10
-rw-r--r--Src/init.c12
-rw-r--r--Src/jobs.c4
3 files changed, 22 insertions, 4 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 004459abf..e68237948 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -595,6 +595,12 @@ execute(LinkList args, int flags, int defpath)
* here, which should be visible to external processes.
*/
closem(FDT_XTRACE);
+#ifndef FD_CLOEXEC
+ if (SHTTY != -1) {
+ close(SHTTY);
+ SHTTY = -1;
+ }
+#endif
child_unblock();
if ((int) strlen(arg0) >= PATH_MAX) {
zerr("command too long: %s", arg0);
@@ -944,7 +950,9 @@ entersubsh(int flags)
}
if (!(sigtrapped[SIGQUIT] & ZSIG_IGNORED))
signal_default(SIGQUIT);
- opts[MONITOR] = opts[USEZLE] = 0;
+ if (!isset(POSIXJOBS))
+ opts[MONITOR] = 0;
+ opts[USEZLE] = 0;
zleactive = 0;
if (flags & ESUB_PGRP)
clearjobtab(monitor);
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, *
diff --git a/Src/jobs.c b/Src/jobs.c
index 8e48ed4b8..df7d9d689 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1292,6 +1292,8 @@ clearjobtab(int monitor)
{
int i;
+ if (isset(POSIXJOBS))
+ oldmaxjob = 0;
for (i = 1; i <= maxjob; i++) {
/*
* See if there is a jobtable worth saving.
@@ -1299,7 +1301,7 @@ clearjobtab(int monitor)
* once for each subshell of a shell with job control,
* so doesn't create a leak.
*/
- if (monitor && jobtab[i].stat)
+ if (monitor && !isset(POSIXJOBS) && jobtab[i].stat)
oldmaxjob = i+1;
else if (jobtab[i].stat & STAT_INUSE)
freejob(jobtab + i, 0);