Mercurial > hg > truffle
comparison mxtool/mx.py @ 4252:67e88b7624d5
Removed need for GRAAL environment variable on Windows.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 09 Jan 2012 22:01:39 +0100 |
parents | c580db4d6f6f |
children | 32b8274f52ad |
comparison
equal
deleted
inserted
replaced
4251:44f3dae303ae | 4252:67e88b7624d5 |
---|---|
542 if pid == process.pid: | 542 if pid == process.pid: |
543 return _returncode(status) | 543 return _returncode(status) |
544 remaining = end - time.time() | 544 remaining = end - time.time() |
545 if remaining <= 0: | 545 if remaining <= 0: |
546 abort('Process timed out after {0} seconds: {1}'.format(timeout, ' '.join(args))) | 546 abort('Process timed out after {0} seconds: {1}'.format(timeout, ' '.join(args))) |
547 _kill_process_group(process.pid) | |
548 delay = min(delay * 2, remaining, .05) | 547 delay = min(delay * 2, remaining, .05) |
549 time.sleep(delay) | 548 time.sleep(delay) |
550 | 549 |
551 # Makes the current subprocess accessible to the abort() function | 550 # Makes the current subprocess accessible to the abort() function |
552 # This is a tuple of the Popen object and args. | 551 # This is a tuple of the Popen object and args. |
574 global _currentSubprocess | 573 global _currentSubprocess |
575 | 574 |
576 try: | 575 try: |
577 # On Unix, the new subprocess should be in a separate group so that a timeout alarm | 576 # On Unix, the new subprocess should be in a separate group so that a timeout alarm |
578 # can use os.killpg() to kill the whole subprocess group | 577 # can use os.killpg() to kill the whole subprocess group |
579 preexec_fn = os.setsid if get_os() != 'windows' else None | 578 preexec_fn = None |
579 creationflags = 0 | |
580 if get_os() == 'windows': | |
581 creationflags = subprocess.CREATE_NEW_PROCESS_GROUP | |
582 else: | |
583 preexec_fn = os.setsid | |
580 | 584 |
581 if not callable(out) and not callable(err) and timeout is None: | 585 if not callable(out) and not callable(err) and timeout is None: |
582 # The preexec_fn=os.setsid | 586 # The preexec_fn=os.setsid |
583 p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn) | 587 p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags) |
584 _currentSubprocess = (p, args) | 588 _currentSubprocess = (p, args) |
585 retcode = p.wait() | 589 retcode = p.wait() |
586 else: | 590 else: |
587 def redirect(stream, f): | 591 def redirect(stream, f): |
588 for line in iter(stream.readline, ''): | 592 for line in iter(stream.readline, ''): |
589 f(line) | 593 f(line) |
590 stream.close() | 594 stream.close() |
591 stdout=out if not callable(out) else subprocess.PIPE | 595 stdout=out if not callable(out) else subprocess.PIPE |
592 stderr=err if not callable(err) else subprocess.PIPE | 596 stderr=err if not callable(err) else subprocess.PIPE |
593 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn) | 597 p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags) |
594 _currentSubprocess = (p, args) | 598 _currentSubprocess = (p, args) |
595 if callable(out): | 599 if callable(out): |
596 t = Thread(target=redirect, args=(p.stdout, out)) | 600 t = Thread(target=redirect, args=(p.stdout, out)) |
597 t.daemon = True # thread dies with the program | 601 t.daemon = True # thread dies with the program |
598 t.start() | 602 t.start() |
742 #import traceback | 746 #import traceback |
743 #traceback.print_stack() | 747 #traceback.print_stack() |
744 currentSubprocess = _currentSubprocess | 748 currentSubprocess = _currentSubprocess |
745 if currentSubprocess is not None: | 749 if currentSubprocess is not None: |
746 p, _ = currentSubprocess | 750 p, _ = currentSubprocess |
747 _kill_process_group(p.pid) | 751 if get_os() == 'windows': |
752 p.kill() | |
753 else: | |
754 _kill_process_group(p.pid) | |
748 | 755 |
749 raise SystemExit(codeOrMessage) | 756 raise SystemExit(codeOrMessage) |
750 | 757 |
751 def download(path, urls, verbose=False): | 758 def download(path, urls, verbose=False): |
752 """ | 759 """ |