Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
4235:23f41c48b19b | 4236:11383dafc318 |
---|---|
515 except OSError, e: | 515 except OSError, e: |
516 if e.errno == errno.EINTR: | 516 if e.errno == errno.EINTR: |
517 continue | 517 continue |
518 raise | 518 raise |
519 | 519 |
520 def _returncode(status): | |
521 if os.WIFSIGNALED(status): | |
522 return -os.WTERMSIG(status) | |
523 elif os.WIFEXITED(status): | |
524 return os.WEXITSTATUS(status) | |
525 else: | |
526 # Should never happen | |
527 raise RuntimeError("Unknown child exit status!") | |
528 | |
520 end = time.time() + timeout | 529 end = time.time() + timeout |
521 delay = 0.0005 | 530 delay = 0.0005 |
522 while True: | 531 while True: |
523 (pid, _) = _waitpid(process.pid) | 532 (pid, status) = _waitpid(process.pid) |
524 if pid == process.pid: | 533 if pid == process.pid: |
525 return process.wait() | 534 return _returncode(status) |
526 remaining = end - time.time() | 535 remaining = end - time.time() |
527 if remaining <= 0: | 536 if remaining <= 0: |
528 process.kill() | 537 process.kill() |
529 abort('Process timed out after {0} seconds: {1}'.format(timeout, ' '.join(args))) | 538 abort('Process timed out after {0} seconds: {1}'.format(timeout, ' '.join(args))) |
530 delay = min(delay * 2, remaining, .05) | 539 delay = min(delay * 2, remaining, .05) |