mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Fixes issue #14396: Handle the odd rare case of waitpid returning 0
when not expected in subprocess.Popen.wait().
This commit is contained in:
parent
c1ce93a4ab
commit
f2705aebb0
2 changed files with 9 additions and 2 deletions
|
@ -1303,7 +1303,7 @@ class Popen(object):
|
||||||
def wait(self):
|
def wait(self):
|
||||||
"""Wait for child process to terminate. Returns returncode
|
"""Wait for child process to terminate. Returns returncode
|
||||||
attribute."""
|
attribute."""
|
||||||
if self.returncode is None:
|
while self.returncode is None:
|
||||||
try:
|
try:
|
||||||
pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
|
pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
|
@ -1312,8 +1312,12 @@ class Popen(object):
|
||||||
# This happens if SIGCLD is set to be ignored or waiting
|
# This happens if SIGCLD is set to be ignored or waiting
|
||||||
# for child processes has otherwise been disabled for our
|
# for child processes has otherwise been disabled for our
|
||||||
# process. This child is dead, we can't get the status.
|
# process. This child is dead, we can't get the status.
|
||||||
|
pid = self.pid
|
||||||
sts = 0
|
sts = 0
|
||||||
self._handle_exitstatus(sts)
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,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.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue