[Python-checkins] cpython (merge 3.3 -> default): Fixes issue #14396: Handle the odd rare case of waitpid returning 0

gregory.p.smith python-checkins at python.org
Sun Nov 11 06:10:45 CET 2012


http://hg.python.org/cpython/rev/512c1120332f
changeset: 80366:512c1120332f
parent: 80360:41280973921a
parent: 80365:80adde16cc94
user: Gregory P. Smith <greg at krypto.org>
date: Sat Nov 10 21:10:31 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 | 10 +++++++---
 Misc/NEWS | 3 +++
 2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1509,9 +1509,13 @@
 raise TimeoutExpired(self.args, timeout)
 delay = min(delay * 2, remaining, .05)
 time.sleep(delay)
- elif self.returncode is None:
- (pid, sts) = self._try_wait(0)
- self._handle_exitstatus(sts)
+ else:
+ while self.returncode is None:
+ (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
 
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -116,6 +116,9 @@
 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
 previously-freed memory. Patch by Serhiy Storchaka.
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /