summaryrefslogtreecommitdiffstats
path: root/Lib/subprocess.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2012-11-11 05:10:31 (GMT)
committerGregory P. Smith <greg@krypto.org>2012-11-11 05:10:31 (GMT)
commitdd0edae1ccef6e0c4ee3338f094ad9d162650360 (patch)
tree406c67bf85555c552f67723213912a427063b9d4 /Lib/subprocess.py
parent0b83224c0ddcb87e2ea139aba5a1e33d70cc9945 (diff)
parenta450c5e69ba17bb47e8b3434969218c97cdf1a07 (diff)
downloadcpython-dd0edae1ccef6e0c4ee3338f094ad9d162650360.zip
cpython-dd0edae1ccef6e0c4ee3338f094ad9d162650360.tar.gz
cpython-dd0edae1ccef6e0c4ee3338f094ad9d162650360.tar.bz2
Fixes issue #14396: Handle the odd rare case of waitpid returning 0
when not expected in subprocess.Popen.wait().
Diffstat (limited to 'Lib/subprocess.py')
-rw-r--r--Lib/subprocess.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 57cc1a4..296613a 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1509,9 +1509,13 @@ class Popen(object):
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