summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-06-09 09:07:54 -0700
committerZac Medico <zmedico@gentoo.org>2011-06-09 09:07:54 -0700
commit88f5bf84e2fd23125910b2ecaffc035971445696 (patch)
tree65a91c4a904b717298e8273bafd152ab0456a320
parent6c5f977d943745f1eaa47da89e32b6c8cd49f41c (diff)
downloadportage-88f5bf84e2fd23125910b2ecaffc035971445696.tar.gz
portage-88f5bf84e2fd23125910b2ecaffc035971445696.tar.bz2
portage-88f5bf84e2fd23125910b2ecaffc035971445696.zip
SubProcess: make returncode like Popen
-rw-r--r--pym/_emerge/SubProcess.py16
1 files 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