about summary refs log tree commit diff
path: root/Src/jobs.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2018-09-12 09:22:10 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2018-09-12 09:22:10 +0100
commit7c5241edf37fbafc9e1f833aede76c524ce62bcb (patch)
tree8168a7eb876ca9018640b77ef9e8a205c7b16ed0 /Src/jobs.c
parent03a51a6f097a6e4a9bb8d94c2be17ec8a2e300b8 (diff)
downloadzsh-7c5241edf37fbafc9e1f833aede76c524ce62bcb.tar.gz
zsh-7c5241edf37fbafc9e1f833aede76c524ce62bcb.tar.xz
zsh-7c5241edf37fbafc9e1f833aede76c524ce62bcb.zip
43446: More entersubsh() / addproc() wiring.
Fix additional races by passing back use of list_pipe_job
from subshell.
Diffstat (limited to 'Src/jobs.c')
-rw-r--r--Src/jobs.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Src/jobs.c b/Src/jobs.c
index ba87a17fa..db2e87ec1 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1375,7 +1375,8 @@ deletejob(Job jn, int disowning)
 
 /**/
 void
-addproc(pid_t pid, char *text, int aux, struct timeval *bgtime, int gleader)
+addproc(pid_t pid, char *text, int aux, struct timeval *bgtime,
+	int gleader, int list_pipe_job_used)
 {
     Process pn, *pnlist;
 
@@ -1397,10 +1398,15 @@ addproc(pid_t pid, char *text, int aux, struct timeval *bgtime, int gleader)
 	 * the job, then it's the group leader.
 	 *
 	 * Exception: if the forked subshell reported its own group
-	 * leader, set that.
+	 * leader, set that.  If it reported the use of list_pipe_job,
+	 * set it for that, too.
 	 */
-	if (!jobtab[thisjob].gleader)
-	    jobtab[thisjob].gleader = (gleader != -1) ? gleader : pid;
+	if (gleader != -1) {
+	    jobtab[thisjob].gleader = gleader;
+	    if (list_pipe_job_used != -1)
+		jobtab[list_pipe_job_used].gleader = gleader;
+	} else if (!jobtab[thisjob].gleader)
+		jobtab[thisjob].gleader = pid;
 	/* attach this process to end of process list of current job */
 	pnlist = &jobtab[thisjob].procs;
     }