diff options
author | Peter Stephenson <p.stephenson@samsung.com> | 2018-09-07 17:49:35 +0100 |
---|---|---|
committer | Peter Stephenson <p.stephenson@samsung.com> | 2018-09-07 17:49:35 +0100 |
commit | 0d5275c6b94e798e813092f37bd40429bd9b0f8b (patch) | |
tree | edebf64f69319c01ef87f221e9f469687cf2694c /Src/jobs.c | |
parent | b2ddd97175c838761b55c11187f12bb6edeee4be (diff) | |
download | zsh-0d5275c6b94e798e813092f37bd40429bd9b0f8b.tar.gz zsh-0d5275c6b94e798e813092f37bd40429bd9b0f8b.tar.xz zsh-0d5275c6b94e798e813092f37bd40429bd9b0f8b.zip |
43409: Fix process group setting in main shell.
A newly forked subshell now reports back the process group it will be using for the main shell to record. This prevents an error where the shell incorrectly thought an exiting process owned the terminal and so grabbed it back, putting the foreground process into the background.
Diffstat (limited to 'Src/jobs.c')
-rw-r--r-- | Src/jobs.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/Src/jobs.c b/Src/jobs.c index 38b3d896b..ba87a17fa 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -1375,7 +1375,7 @@ deletejob(Job jn, int disowning) /**/ void -addproc(pid_t pid, char *text, int aux, struct timeval *bgtime) +addproc(pid_t pid, char *text, int aux, struct timeval *bgtime, int gleader) { Process pn, *pnlist; @@ -1392,10 +1392,15 @@ addproc(pid_t pid, char *text, int aux, struct timeval *bgtime) if (!aux) { pn->bgtime = *bgtime; - /* if this is the first process we are adding to * - * the job, then it's the group leader. */ + /* + * if this is the first process we are adding to + * the job, then it's the group leader. + * + * Exception: if the forked subshell reported its own group + * leader, set that. + */ if (!jobtab[thisjob].gleader) - jobtab[thisjob].gleader = pid; + jobtab[thisjob].gleader = (gleader != -1) ? gleader : pid; /* attach this process to end of process list of current job */ pnlist = &jobtab[thisjob].procs; } |