From 551ff842721d6ca83727dbe6cd40178f46cc8201 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 16 Sep 2018 19:13:38 +0100 Subject: 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. --- Src/jobs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Src/jobs.c') 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 */ -- cgit 1.4.1