Fixes issue #14396: Handle the odd rare case of waitpid returning 0

when not expected in subprocess.Popen.wait().
This commit is contained in:
Gregory P. Smith 2012-11-10 21:06:18 -08:00
commit f328d79223
2 changed files with 10 additions and 3 deletions

View file

@ -1509,9 +1509,13 @@ class Popen(object):
raise TimeoutExpired(self.args, timeout) raise TimeoutExpired(self.args, timeout)
delay = min(delay * 2, remaining, .05) delay = min(delay * 2, remaining, .05)
time.sleep(delay) time.sleep(delay)
elif self.returncode is None: else:
(pid, sts) = self._try_wait(0) while self.returncode is None:
self._handle_exitstatus(sts) (pid, sts) = self._try_wait(0)
# Check the pid and loop as waitpid has been known to return
# 0 even without WNOHANG in odd situations. issue14396.
if pid == self.pid:
self._handle_exitstatus(sts)
return self.returncode return self.returncode

View file

@ -83,6 +83,9 @@ Core and Builtins
Library Library
------- -------
- Issue #14396: Handle the odd rare case of waitpid returning 0 when not
expected in subprocess.Popen.wait().
- Issue #16411: Fix a bug where zlib.decompressobj().flush() might try to access - Issue #16411: Fix a bug where zlib.decompressobj().flush() might try to access
previously-freed memory. Patch by Serhiy Storchaka. previously-freed memory. Patch by Serhiy Storchaka.