changeset 4236:11383dafc318

Fixed bug in getting correct result code for a subprocess executed with a timeout.
author Doug Simon <doug.simon@oracle.com>
date Fri, 06 Jan 2012 15:34:17 +0100
parents 23f41c48b19b
children 30b6720604d2
files mxtool/mx.py
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mxtool/mx.py	Fri Jan 06 14:22:57 2012 +0100
+++ b/mxtool/mx.py	Fri Jan 06 15:34:17 2012 +0100
@@ -517,12 +517,21 @@
                     continue
                 raise
     
+    def _returncode(status):
+        if os.WIFSIGNALED(status):
+            return -os.WTERMSIG(status)
+        elif os.WIFEXITED(status):
+            return os.WEXITSTATUS(status)
+        else:
+            # Should never happen
+            raise RuntimeError("Unknown child exit status!")
+        
     end = time.time() + timeout
     delay = 0.0005
     while True:
-        (pid, _) = _waitpid(process.pid)
+        (pid, status) = _waitpid(process.pid)
         if pid == process.pid:
-            return process.wait()
+            return _returncode(status)
         remaining = end - time.time()
         if remaining <= 0:
             process.kill()