From 88f5bf84e2fd23125910b2ecaffc035971445696 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 9 Jun 2011 09:07:54 -0700 Subject: [PATCH] SubProcess: make returncode like Popen --- pym/_emerge/SubProcess.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py index 115af803d..da2b301db 100644 --- a/pym/_emerge/SubProcess.py +++ b/pym/_emerge/SubProcess.py @@ -124,14 +124,18 @@ class SubProcess(AbstractPollTask): self._files = None def _set_returncode(self, wait_retval): + """ + Set the returncode in a manner compatible with + subprocess.Popen.returncode: A negative value -N indicates + that the child was terminated by signal N (Unix only). + """ - retval = wait_retval[1] + pid, status = wait_retval - if retval != os.EX_OK: - if retval & 0xff: - retval = (retval & 0xff) << 8 - else: - retval = retval >> 8 + if os.WIFSIGNALED(status): + retval = - os.WTERMSIG(status) + else: + retval = os.WEXITSTATUS(status) self.returncode = retval -- 2.26.2