cpython: 82711f5ab507 (original) (raw)
Mercurial > cpython
changeset 80367:82711f5ab507 2.7
Fixes issue #14396: Handle the odd rare case of waitpid returning 0 when not expected in subprocess.Popen.wait(). [#14396]
Gregory P. Smith greg@krypto.org | |
---|---|
date | Sat, 10 Nov 2012 21:13:20 -0800 |
parents | 9b711422c98f |
children | e67620048d2f |
files | Lib/subprocess.py Misc/NEWS |
diffstat | 2 files changed, 9 insertions(+), 2 deletions(-)[+] [-] Lib/subprocess.py 8 Misc/NEWS 3 |
line wrap: on
line diff
--- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1303,7 +1303,7 @@ class Popen(object): def wait(self): """Wait for child process to terminate. Returns returncode attribute."""
if self.returncode is None:[](#l1.7)
while self.returncode is None:[](#l1.8) try:[](#l1.9) pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)[](#l1.10) except OSError as e:[](#l1.11)
@@ -1312,8 +1312,12 @@ class Popen(object): # This happens if SIGCLD is set to be ignored or waiting # for child processes has otherwise been disabled for our # process. This child is dead, we can't get the status.
pid = self.pid[](#l1.16) sts = 0[](#l1.17)
self._handle_exitstatus(sts)[](#l1.18)
# Check the pid and loop as waitpid has been known to return[](#l1.19)
# 0 even without WNOHANG in odd situations. issue14396.[](#l1.20)
if pid == self.pid:[](#l1.21)
self._handle_exitstatus(sts)[](#l1.22) return self.returncode[](#l1.23)
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -143,6 +143,9 @@ Core and Builtins Library ------- +- Issue #14396: Handle the odd rare case of waitpid returning 0 when not