about summary refs log tree commit diff
path: root/Src/jobs.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2018-09-16 19:13:38 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2018-09-16 19:13:38 +0100
commit551ff842721d6ca83727dbe6cd40178f46cc8201 (patch)
tree88fcee0886f87535240a527de45c41fc99de6662 /Src/jobs.c
parent301ca1229a6ca967f8bd7d3c379ff6b9983a3673 (diff)
downloadzsh-551ff842721d6ca83727dbe6cd40178f46cc8201.tar.gz
zsh-551ff842721d6ca83727dbe6cd40178f46cc8201.tar.xz
zsh-551ff842721d6ca83727dbe6cd40178f46cc8201.zip
43464: Another attachtty() fix.
If list_pipe_job triggered more than once we need to know
the most recent process group leader, so record that
both if the attach happened in the main shell on in
entersubsh().

Also don't pass back proocess group for ESUB_ASYNC subshells.
Diffstat (limited to 'Src/jobs.c')
-rw-r--r--Src/jobs.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Src/jobs.c b/Src/jobs.c
index db2e87ec1..2d58319a8 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -40,6 +40,11 @@ mod_export pid_t origpgrp;
 
 /**/
 mod_export pid_t mypgrp;
+
+/* the last process group to attach to the terminal */
+
+/**/
+pid_t last_attached_pgrp;
  
 /* the job we are working on */
  
@@ -1405,6 +1410,11 @@ addproc(pid_t pid, char *text, int aux, struct timeval *bgtime,
 	    jobtab[thisjob].gleader = gleader;
 	    if (list_pipe_job_used != -1)
 		jobtab[list_pipe_job_used].gleader = gleader;
+	    /*
+	     * Record here this is the latest process group to grab the
+	     * terminal as attachtty() was run in the subshell.
+	     */
+	    last_attached_pgrp = gleader;
 	} else if (!jobtab[thisjob].gleader)
 		jobtab[thisjob].gleader = pid;
 	/* attach this process to end of process list of current job */