summaryrefslogtreecommitdiff
path: root/Src/init.c
diff options
context:
space:
mode:
authorStephane Chazelas <stephane@chazelas.org>2024-02-18 18:52:50 +0000
committerStephane Chazelas <stephane@chazelas.org>2024-02-18 18:56:39 +0000
commitf1e7481b8690a6ef71a83853f05645cb774778ab (patch)
tree1e6c56c47891a6f412efda764d1e5b53279ae972 /Src/init.c
parentc2cf21c8f012db611bab1c92ee68e8af9d09fb65 (diff)
downloadzsh-f1e7481b8690a6ef71a83853f05645cb774778ab.tar.gz
zsh-f1e7481b8690a6ef71a83853f05645cb774778ab.zip
45837: fix process group restoration upon exit
Diffstat (limited to 'Src/init.c')
-rw-r--r--Src/init.c13
1 files changed, 8 insertions, 5 deletions
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