changeset 4293:d4906ea4255b

Handle SIGTERM : killing mx will properly kill subprocesses Some tabs/spaces mixups
author Gilles Duboscq <gilles.m.duboscq@gmail.com>
date Wed, 18 Jan 2012 16:53:04 +0100
parents 48cbd78fa964
children 600cbdce9805
files mx/commands.py mxtool/mx.py
diffstat 2 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mx/commands.py	Tue Jan 17 19:38:48 2012 -0800
+++ b/mx/commands.py	Wed Jan 18 16:53:04 2012 +0100
@@ -516,8 +516,8 @@
         index = args.index('-resultfile')
         if index + 1 < len(args):
             resultFile = args[index + 1]
-	    del args[index]
-	    del args[index]
+            del args[index]
+            del args[index]
         else:
             mx.abort('-resultfile must be followed by a file name')
     vm = 'graal'
@@ -526,7 +526,7 @@
         if index + 1 < len(args):
             vm = args[index + 1]
             del args[index]
-	    del args[index]
+            del args[index]
         else:
             mx.abort('-vm must be followed by a vm name (graal, server, client..)')
     if len(args) is 0:
--- a/mxtool/mx.py	Tue Jan 17 19:38:48 2012 -0800
+++ b/mxtool/mx.py	Wed Jan 18 16:53:04 2012 +0100
@@ -576,7 +576,7 @@
     if timeout is None and _opts.ptimeout != 0:
         timeout = _opts.ptimeout
 
-    global _currentSubprocess    
+    global _currentSubprocess
         
     try:
         # On Unix, the new subprocess should be in a separate group so that a timeout alarm
@@ -1618,6 +1618,9 @@
         abort('mx: unknown command \'{0}\'\n{1}use "mx help" for more options'.format(command, _format_commands()))
         
     c, _ = commands[command][:2]
+    def term_handler(signum, frame):
+        abort(1)
+    signal.signal(signal.SIGTERM, term_handler)
     try:
         if opts.timeout != 0:
             def alarm_handler(signum, frame):