diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2011-04-01 11:02:15 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2011-04-01 11:02:15 +0000 |
commit | 47d1215cb43a8b6388b1f6e3f8368676e6f2aa93 (patch) | |
tree | 10cb1dd1164e9cde619b975491fb6bb0f213c40a /Src | |
parent | eb46727d3a03f2282e811664eee68c7e581c3277 (diff) | |
download | zsh-47d1215cb43a8b6388b1f6e3f8368676e6f2aa93.tar.gz zsh-47d1215cb43a8b6388b1f6e3f8368676e6f2aa93.tar.xz zsh-47d1215cb43a8b6388b1f6e3f8368676e6f2aa93.zip |
Stef van Vlierberghe: 28965 (as posted in 28967):
findproc() should not return processes not marked as SP_RUNNING
Diffstat (limited to 'Src')
-rw-r--r-- | Src/jobs.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Src/jobs.c b/Src/jobs.c index fd785a0e9..9a8dc8fea 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -173,11 +173,28 @@ findproc(pid_t pid, Job *jptr, Process *pptr, int aux) for (pn = aux ? jobtab[i].auxprocs : jobtab[i].procs; pn; pn = pn->next) - if (pn->pid == pid) { + { + /* + * Make sure we match a process that's still running. + * + * When a job contains two pids, one terminated pid and one + * running pid, then the condition (jobtab[i].stat & + * STAT_DONE) will not stop these pids from being candidates + * for the findproc result (which is supposed to be a + * RUNNING pid), and if the terminated pid is an identical + * process number for the pid identifying the running + * process we are trying to find (after pid number + * wrapping), then we need to avoid returning the terminated + * pid, otherwise the shell would block and wait forever for + * the termination of the process which pid we were supposed + * to return in a different job. + */ + if (pn->pid == pid && pn->status == SP_RUNNING) { *pptr = pn; *jptr = jobtab + i; return 1; } + } } return 0; |