diff mxtool/mx.py @ 4396:4023bae16d02

Make mx script killable on Windows. renamed mx.bat to mx.cmd.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 28 Jan 2012 23:14:46 +0100
parents 8dd27e218e19
children 7903b6c28f9c
line wrap: on
line diff
--- a/mxtool/mx.py	Sat Jan 28 22:27:36 2012 +0100
+++ b/mxtool/mx.py	Sat Jan 28 23:14:46 2012 +0100
@@ -592,7 +592,14 @@
             # The preexec_fn=os.setsid
             p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags)
             _currentSubprocess = (p, args)
-            retcode = p.wait()
+            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()            
         else:
             def redirect(stream, f):
                 for line in iter(stream.readline, ''):