diff mxtool/mx.py @ 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 311d193de5a2
children 8dd27e218e19
line wrap: on
line diff
--- 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):