Mercurial > hg > truffle
diff mxtool/mx.py @ 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 | 057620486c90 |
children | 676feaf8adee |
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()