1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-06-12 19:38:03 +02:00

45837: fix process group restoration upon exit

This commit is contained in:
Stephane Chazelas 2024-02-18 18:52:50 +00:00
parent c2cf21c8f0
commit f1e7481b86
4 changed files with 19 additions and 9 deletions

View file

@ -1,3 +1,9 @@
2024-02-18 Stephane Chazelas <stephane@chazelas.org>
* 45837: Src/exec.c, Src/init.c, Src/options.c: fix issue whereby
original process group is not restored properly upon exit when
exec {var} redirs are used or MONITOR is temporarily disabled.
2024-02-18 Stephane Chazelas <stephane@chazelas.org> 2024-02-18 Stephane Chazelas <stephane@chazelas.org>
* 52515: Src/exec.c (+ tests in 52527) avoid sh errors when * 52515: Src/exec.c (+ tests in 52527) avoid sh errors when

View file

@ -3768,7 +3768,7 @@ execcmd_exec(Estate state, Execcmd_params eparams,
addfd(forked, save, mfds, fn->fd1, fil, 0, fn->varid); addfd(forked, save, mfds, fn->fd1, fil, 0, fn->varid);
/* If this is 'exec < file', read from stdin, * /* If this is 'exec < file', read from stdin, *
* not terminal, unless `file' is a terminal. */ * 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) isset(SHINSTDIN) && interact && !zleactive)
init_io(NULL); init_io(NULL);
break; break;

View file

@ -700,11 +700,14 @@ init_io(char *cmd)
* process group leader. * process group leader.
*/ */
mypid = (zlong)getpid(); mypid = (zlong)getpid();
if (opts[MONITOR] && (SHTTY != -1)) { if (opts[MONITOR]) {
origpgrp = GETPGRP(); if (SHTTY == -1)
acquire_pgrp(); /* might also clear opts[MONITOR] */ opts[MONITOR] = 0;
} else else if (!origpgrp) {
opts[MONITOR] = 0; origpgrp = GETPGRP();
acquire_pgrp(); /* might also clear opts[MONITOR] */
}
}
#else #else
opts[MONITOR] = 0; opts[MONITOR] = 0;
#endif #endif

View file

@ -881,11 +881,12 @@ dosetopt(int optno, int value, int force, char *new_opts)
} else if (!force && optno == MONITOR && value) { } else if (!force && optno == MONITOR && value) {
if (new_opts[optno] == value) if (new_opts[optno] == value)
return 0; return 0;
if (SHTTY != -1) { if (SHTTY == -1)
return -1;
if (!origpgrp) {
origpgrp = GETPGRP(); origpgrp = GETPGRP();
acquire_pgrp(); acquire_pgrp();
} else }
return -1;
#else #else
} else if(optno == MONITOR && value) { } else if(optno == MONITOR && value) {
return -1; return -1;