diff 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
line wrap: on
line diff
--- a/mxtool/mx.py	Mon Jan 09 16:03:02 2012 +0100
+++ b/mxtool/mx.py	Mon Jan 09 22:01:39 2012 +0100
@@ -544,7 +544,6 @@
         remaining = end - time.time()
         if remaining <= 0:
             abort('Process timed out after {0} seconds: {1}'.format(timeout, ' '.join(args)))
-            _kill_process_group(process.pid)
         delay = min(delay * 2, remaining, .05)
         time.sleep(delay)
 
@@ -576,11 +575,16 @@
     try:
         # On Unix, the new subprocess should be in a separate group so that a timeout alarm
         # can use os.killpg() to kill the whole subprocess group
-        preexec_fn = os.setsid if get_os() != 'windows' else None
+        preexec_fn = None
+        creationflags = 0
+        if get_os() == 'windows':
+            creationflags = subprocess.CREATE_NEW_PROCESS_GROUP
+        else:
+            preexec_fn = os.setsid  
         
         if not callable(out) and not callable(err) and timeout is None:
             # The preexec_fn=os.setsid
-            p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn)
+            p = subprocess.Popen(args, cwd=cwd, preexec_fn=preexec_fn, creationflags=creationflags)
             _currentSubprocess = (p, args)
             retcode = p.wait()
         else:
@@ -590,7 +594,7 @@
                 stream.close()
             stdout=out if not callable(out) else subprocess.PIPE
             stderr=err if not callable(err) else subprocess.PIPE
-            p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn)
+            p = subprocess.Popen(args, cwd=cwd, stdout=stdout, stderr=stderr, preexec_fn=preexec_fn, creationflags=creationflags)
             _currentSubprocess = (p, args)
             if callable(out):
                 t = Thread(target=redirect, args=(p.stdout, out))
@@ -744,7 +748,10 @@
     currentSubprocess = _currentSubprocess
     if currentSubprocess is not None:
         p, _ = currentSubprocess
-        _kill_process_group(p.pid)
+        if get_os() == 'windows':
+            p.kill()
+        else:
+            _kill_process_group(p.pid)
     
     raise SystemExit(codeOrMessage)