diff options
author | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2020-02-27 20:42:16 +0000 |
---|---|---|
committer | Peter Stephenson <p.w.stephenson@ntlworld.com> | 2020-02-27 20:42:16 +0000 |
commit | 14ea665a903b26a658ef1d2ca974a9b48e09eff1 (patch) | |
tree | 443a5225cfac4052123b81c4d7c5b7ee5a5220c7 /Src/jobs.c | |
parent | fe516fccb4754833f850cb62f6607226370bbf53 (diff) | |
download | zsh-14ea665a903b26a658ef1d2ca974a9b48e09eff1.tar.gz zsh-14ea665a903b26a658ef1d2ca974a9b48e09eff1.tar.xz zsh-14ea665a903b26a658ef1d2ca974a9b48e09eff1.zip |
users/24710: Fix job control problem with sudo.
If we use kill to test for continued existence of a process group, we should check on failure that the error is ESRCH, as EPERM indicates the group still has memebers but running privileged so should be left alone.
Diffstat (limited to 'Src/jobs.c')
-rw-r--r-- | Src/jobs.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Src/jobs.c b/Src/jobs.c index 0485f2c7c..8353f1152 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -283,7 +283,8 @@ handle_sub(int job, int fg) if ((cp = ((WIFEXITED(jn->procs->status) || WIFSIGNALED(jn->procs->status)) && - killpg(jn->gleader, 0) == -1))) { + (killpg(jn->gleader, 0) == -1 && + errno == ESRCH)))) { Process p; for (p = jn->procs; p->next; p = p->next); jn->gleader = p->pid; @@ -541,9 +542,13 @@ update_job(Job jn) /* is this job in the foreground of an interactive shell? */ if (mypgrp != pgrp && inforeground && - (jn->gleader == pgrp || (pgrp > 1 && kill(-pgrp, 0) == -1))) { + (jn->gleader == pgrp || + (pgrp > 1 && + (kill(-pgrp, 0) == -1 && errno == ESRCH)))) { if (list_pipe) { - if (somestopped || (pgrp > 1 && kill(-pgrp, 0) == -1)) { + if (somestopped || (pgrp > 1 && + kill(-pgrp, 0) == -1 && + errno == ESRCH)) { attachtty(mypgrp); /* check window size and adjust if necessary */ adjustwinsize(0); @@ -2470,7 +2475,8 @@ bin_fg(char *name, char **argv, Options ops, int func) if ((jobtab[job].stat & STAT_SUPERJOB) && ((!jobtab[job].procs->next || (jobtab[job].stat & STAT_SUBLEADER) || - killpg(jobtab[job].gleader, 0) == -1)) && + (killpg(jobtab[job].gleader, 0) == -1 && + errno == ESRCH))) && jobtab[jobtab[job].other].gleader) attachtty(jobtab[jobtab[job].other].gleader); else |