From 98b29d02ca17068779f4b8fa2d43c9753386478f Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Wed, 15 Jun 2011 15:38:14 +0000 Subject: 29481: always return a matching job in findproc() but scan the whole list to prefer running jobs --- ChangeLog | 9 ++++++++- Src/jobs.c | 10 ++++++---- Src/signals.c | 1 - 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50b31765d..0116bab38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2011-06-15 Barton E. Schaefer + + * 29481: Src/jobs.c, Src/signals.c: always return a matching job + in findproc() [reverses 28967 and 29472], but scan the whole list + to prefer running jobs in the rare event that one running and one + exited job share a PID. + 2011-06-14 Peter Stephenson * unposted: Doc/Zsh/compwid.yo: document change to brace @@ -14990,5 +14997,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5369 $ +* $Revision: 1.5370 $ ***************************************************** diff --git a/Src/jobs.c b/Src/jobs.c index 0ace80b63..9c9b12f5e 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -160,6 +160,8 @@ findproc(pid_t pid, Job *jptr, Process *pptr, int aux) Process pn; int i; + *jptr = NULL; + *pptr = NULL; for (i = 1; i <= maxjob; i++) { /* @@ -189,16 +191,16 @@ findproc(pid_t pid, Job *jptr, Process *pptr, int aux) * the termination of the process which pid we were supposed * to return in a different job. */ - if (pn->pid == pid && (pn->status == SP_RUNNING || - WIFSTOPPED(pn->status))) { + if (pn->pid == pid) { *pptr = pn; *jptr = jobtab + i; - return 1; + if (pn->status == SP_RUNNING) + return 1; } } } - return 0; + return (*pptr && *jptr); } /* Does the given job number have any processes? */ diff --git a/Src/signals.c b/Src/signals.c index 456a85300..a848acdbe 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -489,7 +489,6 @@ wait_for_processes(void) * Find the process and job containing this pid and * update it. */ - pn = NULL; if (findproc(pid, &jn, &pn, 0)) { #if defined(HAVE_WAIT3) && defined(HAVE_GETRUSAGE) struct timezone dummy_tz; -- cgit v1.2.3-70-g09d2