From 3206b8a2eac54b75a181859cd98130c5219c3126 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 2 Dec 2009 09:46:12 +0000 Subject: 27442 plus tweak: wait returns status for $! even if exited --- Src/signals.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Src/signals.c') diff --git a/Src/signals.c b/Src/signals.c index 4bc1de016..f67a3e8ca 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -530,6 +530,7 @@ zhandler(int sig) * 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; @@ -551,6 +552,15 @@ zhandler(int sig) */ get_usage(); } + /* + * Remember the status associated with $!, so we can + * wait for it even if it's exited. This value is + * only used if we can't find the PID in the job table, + * so it doesn't matter that the value we save here isn't + * useful until the process has exited. + */ + if (pn != NULL && pid == lastpid && lastpid_status != -1L) + lastpid_status = lastval2; } break; -- cgit 1.4.1