diff options
author | Gregory P. Smith <greg@krypto.org> | 2012-11-11 05:06:18 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2012-11-11 05:06:18 (GMT) |
commit | f328d792235e16397c109d7b85a34ab5efce9498 (patch) | |
tree | b5332e7619c2d861df98f000c5ec2401ecf8061b /Lib/subprocess.py | |
parent | 34b14951eeb235ac0e0cbbd2ccd5d72d178dd983 (diff) | |
parent | 2ec82331b25bb1542113f65c70e41932831fe546 (diff) | |
download | cpython-f328d792235e16397c109d7b85a34ab5efce9498.zip cpython-f328d792235e16397c109d7b85a34ab5efce9498.tar.gz cpython-f328d792235e16397c109d7b85a34ab5efce9498.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.py | 10 |
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 |