diff options
author | Peter Stephenson <p.stephenson@samsung.com> | 2018-03-12 15:26:34 +0000 |
---|---|---|
committer | Peter Stephenson <p.stephenson@samsung.com> | 2018-03-12 15:26:34 +0000 |
commit | 7fd8e380bfc36013acf157de82dbf39e314d3dc4 (patch) | |
tree | 44b0a8ccfafb89637017da6dbdde7c796d5bd216 | |
parent | c3133f5eb140c42d64a49804518bb6d2e0e8d629 (diff) | |
download | zsh-7fd8e380bfc36013acf157de82dbf39e314d3dc4.tar.gz zsh-7fd8e380bfc36013acf157de82dbf39e314d3dc4.tar.xz zsh-7fd8e380bfc36013acf157de82dbf39e314d3dc4.zip |
42453: Fix race in look up of status for wait.
Background jobs that had just exited could still be in the table when the process had already finished and the status was recorded, causing the wrong status to be reported.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Src/jobs.c | 7 |
2 files changed, 10 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog index 602289263..97e23e456 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2018-03-12 Peter Stephenson <p.stephenson@samsung.com> + + * 42453: Src/jobs.c: fix race looking up status of just + exited background job. + 2018-03-07 Oliver Kiddle <okiddle@yahoo.co.uk> * github #22: Ferenc-: Completion/Unix/Command/_gcc: diff --git a/Src/jobs.c b/Src/jobs.c index 503618f47..330ee6b37 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -2289,8 +2289,11 @@ bin_fg(char *name, char **argv, Options ops, int func) */ retval = waitforpid(pid, 1); } - if (retval == 0) - retval = lastval2; + if (retval == 0) { + if ((retval = getbgstatus(pid)) < 0) { + retval = lastval2; + } + } } else if ((retval = getbgstatus(pid)) < 0) { zwarnnam(name, "pid %d is not a child of this shell", pid); /* presumably lastval2 doesn't tell us a heck of a lot? */ |