summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c2
-rw-r--r--Src/init.c13
-rw-r--r--Src/options.c7
3 files changed, 13 insertions, 9 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 9c8bbb458..1565cb13e 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3768,7 +3768,7 @@ execcmd_exec(Estate state, Execcmd_params eparams,
addfd(forked, save, mfds, fn->fd1, fil, 0, fn->varid);
/* If this is 'exec < file', read from stdin, *
* not terminal, unless `file' is a terminal. */
- if (nullexec == 1 && fn->fd1 == 0 &&
+ if (nullexec == 1 && fn->fd1 == 0 && !fn->varid &&
isset(SHINSTDIN) && interact && !zleactive)
init_io(NULL);
break;
diff --git a/Src/init.c b/Src/init.c
index 799ad19f6..83b79d3d4 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -700,11 +700,14 @@ init_io(char *cmd)
* process group leader.
*/
mypid = (zlong)getpid();
- if (opts[MONITOR] && (SHTTY != -1)) {
- origpgrp = GETPGRP();
- acquire_pgrp(); /* might also clear opts[MONITOR] */
- } else
- opts[MONITOR] = 0;
+ if (opts[MONITOR]) {
+ if (SHTTY == -1)
+ opts[MONITOR] = 0;
+ else if (!origpgrp) {
+ origpgrp = GETPGRP();
+ acquire_pgrp(); /* might also clear opts[MONITOR] */
+ }
+ }
#else
opts[MONITOR] = 0;
#endif
diff --git a/Src/options.c b/Src/options.c
index a994b563e..a0e1aa024 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -881,11 +881,12 @@ dosetopt(int optno, int value, int force, char *new_opts)
} else if (!force && optno == MONITOR && value) {
if (new_opts[optno] == value)
return 0;
- if (SHTTY != -1) {
+ if (SHTTY == -1)
+ return -1;
+ if (!origpgrp) {
origpgrp = GETPGRP();
acquire_pgrp();
- } else
- return -1;
+ }
#else
} else if(optno == MONITOR && value) {
return -1;