# HG changeset patch # User Doug Simon # Date 1325860457 -3600 # Node ID 11383dafc318c0174d8c724267b3f637f0ff21ff # Parent 23f41c48b19bffd5f1590564bad1922ea5d3af23 Fixed bug in getting correct result code for a subprocess executed with a timeout. diff -r 23f41c48b19b -r 11383dafc318 mxtool/mx.py --- 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()