changeset 4660:b06ade6e927c

Fixed Ctrl+C for Windows in mx.py
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 21 Feb 2012 19:30:33 +0100
parents bb90e461a139
children 9ae5048b9153
files mx/commands.py mxtool/mx.py
diffstat 2 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- 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)
 
 
--- 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')