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:
Gregory P. Smith 2012-09-29 11:40:38 -07:00
parent 5320250485
commit 3905171f1e
3 changed files with 22 additions and 2 deletions

View file

@ -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