From a58e2c5c4928ae8031ee60a97f2ab4f863aff8cb Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 20 May 2016 12:08:12 +0200 Subject: [PATCH] Issue #26741: POSIX implementation of subprocess.Popen._execute_child() now sets the returncode attribute using the child process exit status when exec failed. --- Lib/subprocess.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Lib/subprocess.py b/Lib/subprocess.py index 642c7f21822..41a9de10f5e 100644 --- a/Lib/subprocess.py +++ b/Lib/subprocess.py @@ -1524,9 +1524,14 @@ class Popen(object): if errpipe_data: try: - os.waitpid(self.pid, 0) + pid, sts = os.waitpid(self.pid, 0) + if pid == self.pid: + self._handle_exitstatus(sts) + else: + self.returncode = sys.maxsize except ChildProcessError: pass + try: exception_name, hex_errno, err_msg = ( errpipe_data.split(b':', 2))