mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #29335: Fix subprocess.Popen.wait() when the child process has
exited to a stopped instead of terminated state (ex: when under ptrace).
This commit is contained in:
commit
78034c81fb
3 changed files with 48 additions and 1 deletions
|
@ -1329,7 +1329,8 @@ class Popen(object):
|
|||
|
||||
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
|
||||
_WTERMSIG=os.WTERMSIG, _WIFEXITED=os.WIFEXITED,
|
||||
_WEXITSTATUS=os.WEXITSTATUS):
|
||||
_WEXITSTATUS=os.WEXITSTATUS, _WIFSTOPPED=os.WIFSTOPPED,
|
||||
_WSTOPSIG=os.WSTOPSIG):
|
||||
"""All callers to this function MUST hold self._waitpid_lock."""
|
||||
# This method is called (indirectly) by __del__, so it cannot
|
||||
# refer to anything outside of its local scope.
|
||||
|
@ -1337,6 +1338,8 @@ class Popen(object):
|
|||
self.returncode = -_WTERMSIG(sts)
|
||||
elif _WIFEXITED(sts):
|
||||
self.returncode = _WEXITSTATUS(sts)
|
||||
elif _WIFSTOPPED(sts):
|
||||
self.returncode = -_WSTOPSIG(sts)
|
||||
else:
|
||||
# Should never happen
|
||||
raise SubprocessError("Unknown child exit status!")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue