From 50e16e33af69aca6e908bace793178c8d6ab8272 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sun, 22 Jan 2017 17:28:38 -0800 Subject: Issue #29335: Fix subprocess.Popen.wait() when the child process has exited to a stopped instead of terminated state (ex: when under ptrace). --- Lib/subprocess.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Lib/subprocess.py') diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 502e26b9c4..21655242a4 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1285,7 +1285,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. @@ -1293,6 +1294,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!") -- cgit v1.2.1