[Python-checkins] cpython (3.2): Fixes issue #14396: Handle the odd rare case of waitpid returning 0 when
gregory.p.smith
python-checkins at python.org
Sun Nov 11 06:10:40 CET 2012
http://hg.python.org/cpython/rev/d478df13abde
changeset: 80362:d478df13abde
branch: 3.2
parent: 80358:ba45976c2801
user: Gregory P. Smith <greg at krypto.org>
date: Sat Nov 10 20:52:29 2012 -0800
summary:
Fixes issue #14396: Handle the odd rare case of waitpid returning 0 when
not expected in subprocess.Popen.wait().
files:
Lib/subprocess.py | 8 ++++++--
Misc/NEWS | 3 +++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1428,7 +1428,7 @@
def wait(self):
"""Wait for child process to terminate. Returns returncode
attribute."""
- if self.returncode is None:
+ while self.returncode is None:
try:
pid, sts = _eintr_retry_call(os.waitpid, self.pid, 0)
except OSError as e:
@@ -1437,8 +1437,12 @@
# 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
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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,9 @@
Core and Builtins
-----------------
+- Issue #14396: Handle the odd rare case of waitpid returning 0 when not
+ expected in subprocess.Popen.wait().
+
- Issue #9535: Fix pending signals that have been received but not yet
handled by Python to not persist after os.fork() in the child process.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list