mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Fixes issue #15756: subprocess.poll() now properly handles errno.ECHILD
to return a returncode of 0 when the child has already exited or cannot be waited on.
This commit is contained in:
parent
5320250485
commit
3905171f1e
3 changed files with 22 additions and 2 deletions
|
@ -1400,9 +1400,16 @@ class Popen(object):
|
|||
pid, sts = _waitpid(self.pid, _WNOHANG)
|
||||
if pid == self.pid:
|
||||
self._handle_exitstatus(sts)
|
||||
except _os_error:
|
||||
except _os_error as e:
|
||||
if _deadstate is not None:
|
||||
self.returncode = _deadstate
|
||||
elif e.errno == errno.ECHILD:
|
||||
# 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.
|
||||
# http://bugs.python.org/issue15756
|
||||
self.returncode = 0
|
||||
return self.returncode
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue