# HG changeset patch # User Thomas Wuerthinger # Date 1329849033 -3600 # Node ID b06ade6e927c644d309e2b1fe2fa260d13456e58 # Parent bb90e461a1395cdccec0ab9a0cdf2f4e1114762d Fixed Ctrl+C for Windows in mx.py diff -r bb90e461a139 -r b06ade6e927c mx/commands.py --- a/mx/commands.py Tue Feb 21 15:57:18 2012 +0100 +++ b/mx/commands.py Tue Feb 21 19:30:33 2012 +0100 @@ -476,7 +476,6 @@ if mx.java().debug: args = ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000'] + args exe = join(_jdk(build), 'bin', mx.exe_suffix('java')) - print('Executing VM ' + exe) return mx.run([exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) diff -r bb90e461a139 -r b06ade6e927c mxtool/mx.py --- a/mxtool/mx.py Tue Feb 21 15:57:18 2012 +0100 +++ b/mxtool/mx.py Tue Feb 21 19:30:33 2012 +0100 @@ -557,6 +557,17 @@ # This is a tuple of the Popen object and args. _currentSubprocess = None +def waitOn(p): + if get_os() == 'windows': + # on windows use a poll loop, otherwise signal does not get handled + retcode = None + while retcode == None: + retcode = p.poll() + time.sleep(0.05) + else: + retcode = p.wait() + return retcode + def run(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None): """ Run a command in a subprocess, wait for it to complete and return the exit status of the process. @@ -592,14 +603,7 @@ # The preexec_fn=os.setsid p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags) _currentSubprocess = (p, args) - if get_os() == 'windows': - # on windows use a poll loop, otherwise signal does not get handled - retcode = None - while retcode == None: - retcode = p.poll() - time.sleep(0.05) - else: - retcode = p.wait() + waitOn(p) else: def redirect(stream, f): for line in iter(stream.readline, ''): @@ -618,7 +622,7 @@ t.daemon = True # thread dies with the program t.start() if timeout is None or timeout == 0: - retcode = p.wait() + retcode = waitOn(p) else: if get_os() == 'windows': abort('Use of timeout not (yet) supported on Windows')