From 30d2d12c5b38a0594e4beb9ec4ac46342657555e Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Wed, 6 Nov 2013 14:48:34 -0500 Subject: [PATCH] Bug 935677 - Exit status reported by `wait` is incorrect Unshift the value returned by `os.waitpid()`. --- mozprocess/mozprocess/processhandler.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mozprocess/mozprocess/processhandler.py b/mozprocess/mozprocess/processhandler.py index e9bedb4..870224b 100644 --- a/mozprocess/mozprocess/processhandler.py +++ b/mozprocess/mozprocess/processhandler.py @@ -521,8 +521,14 @@ def _wait(self): if not self._ignore_children: try: - # os.waitpid returns a (pid, status) tuple - return os.waitpid(self.pid, 0)[1] + # os.waitpid return value: + # > [...] a tuple containing its pid and exit status + # > indication: a 16-bit number, whose low byte is the + # > signal number that killed the process, and whose + # > high byte is the exit status (if the signal number + # > is zero) + # - http://docs.python.org/2/library/os.html#os.wait + return os.waitpid(self.pid, 0)[1] >> 8 except OSError, e: if getattr(e, "errno", None) != 10: # Error 10 is "no child process", which could indicate normal @@ -736,6 +742,8 @@ def wait(self, timeout=None): If timeout is not None, will return after timeout seconds. This timeout only causes the wait function to return and does not kill the process. + + Returns the process's exit code. """ if self.outThread: # Thread.join() blocks the main thread until outThread is finished