about summary refs log tree commit diff
path: root/Src/signals.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2018-04-13 12:09:34 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2018-04-17 17:14:20 +0100
commit3c74891fcd68d37c1629943f703ac70428e3ce9f (patch)
treeb6da0e207af9a39e94e6e809690c5ea16b14b08c /Src/signals.c
parent181f5cfabe2a60d668f4e5fc03359df1b13ce490 (diff)
downloadzsh-3c74891fcd68d37c1629943f703ac70428e3ce9f.tar.gz
zsh-3c74891fcd68d37c1629943f703ac70428e3ce9f.tar.xz
zsh-3c74891fcd68d37c1629943f703ac70428e3ce9f.zip
42630: Improve process group handling in pipelines.
If process group leader exits, allow a newly forked process to become
process leader.  If a foreground job, reattach the shell to the
terminal until that happens.

Unblock signals when reading output for command subsitution so that
we can do this reattaching immediately.
Diffstat (limited to 'Src/signals.c')
-rw-r--r--Src/signals.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/Src/signals.c b/Src/signals.c
index 94f379e72..2a6aa3f24 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -537,6 +537,19 @@ wait_for_processes(void)
 #else
 		update_process(pn, status);
 #endif
+		if (pn->pid == jn->gleader) {
+		    jn->gleader = 0;
+		    if (!(jn->stat & STAT_NOSTTY)) {
+			/*
+			 * This PID was in control of the terminal;
+			 * reclaim terminal now it has exited.
+			 * It's still possible some future forked
+			 * process of this job will become group
+			 * leader, however.
+			 */
+			attachtty(mypgrp);
+		    }
+		}
 	    }
 	    update_job(jn);
 	} else if (findproc(pid, &jn, &pn, 1)) {