Mercurial > hg > truffle
comparison mxtool/mx.py @ 14135:ee66410c0679
mx: add option to send sigquit before killing child
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Tue, 11 Mar 2014 17:48:21 +0100 |
parents | e71d421370f3 |
children | 38c0db058dcd |
comparison
equal
deleted
inserted
replaced
14134:e71d421370f3 | 14135:ee66410c0679 |
---|---|
1030 self.add_argument('--Jp', action='append', dest='java_args_pfx', help='prefix Java VM arguments (e.g. --Jp @-dsa)', metavar='@<args>', default=[]) | 1030 self.add_argument('--Jp', action='append', dest='java_args_pfx', help='prefix Java VM arguments (e.g. --Jp @-dsa)', metavar='@<args>', default=[]) |
1031 self.add_argument('--Ja', action='append', dest='java_args_sfx', help='suffix Java VM arguments (e.g. --Ja @-dsa)', metavar='@<args>', default=[]) | 1031 self.add_argument('--Ja', action='append', dest='java_args_sfx', help='suffix Java VM arguments (e.g. --Ja @-dsa)', metavar='@<args>', default=[]) |
1032 self.add_argument('--user-home', help='users home directory', metavar='<path>', default=os.path.expanduser('~')) | 1032 self.add_argument('--user-home', help='users home directory', metavar='<path>', default=os.path.expanduser('~')) |
1033 self.add_argument('--java-home', help='bootstrap JDK installation directory (must be JDK 6 or later)', metavar='<path>') | 1033 self.add_argument('--java-home', help='bootstrap JDK installation directory (must be JDK 6 or later)', metavar='<path>') |
1034 self.add_argument('--ignore-project', action='append', dest='ignored_projects', help='name of project to ignore', metavar='<name>', default=[]) | 1034 self.add_argument('--ignore-project', action='append', dest='ignored_projects', help='name of project to ignore', metavar='<name>', default=[]) |
1035 self.add_argument('--kill-with-sigquit', action='store_true', dest='killwithsigquit', help='send sigquit first before killing child processes') | |
1035 if get_os() != 'windows': | 1036 if get_os() != 'windows': |
1036 # Time outs are (currently) implemented with Unix specific functionality | 1037 # Time outs are (currently) implemented with Unix specific functionality |
1037 self.add_argument('--timeout', help='timeout (in seconds) for command', type=int, default=0, metavar='<secs>') | 1038 self.add_argument('--timeout', help='timeout (in seconds) for command', type=int, default=0, metavar='<secs>') |
1038 self.add_argument('--ptimeout', help='timeout (in seconds) for subprocesses', type=int, default=0, metavar='<secs>') | 1039 self.add_argument('--ptimeout', help='timeout (in seconds) for subprocesses', type=int, default=0, metavar='<secs>') |
1039 | 1040 |
1461 result = expandvars(value) | 1462 result = expandvars(value) |
1462 if '$' in result or '%' in result: | 1463 if '$' in result or '%' in result: |
1463 abort('Property contains an undefined environment variable: ' + value) | 1464 abort('Property contains an undefined environment variable: ' + value) |
1464 return result | 1465 return result |
1465 | 1466 |
1466 | 1467 def _send_sigquit(): |
1467 def quit_handler(signum, frame): | |
1468 p, _ = _currentSubprocess | 1468 p, _ = _currentSubprocess |
1469 if p is not None: | 1469 if p is not None: |
1470 if get_os() == 'windows': | 1470 if get_os() == 'windows': |
1471 log("mx: implement me! want to send SIGQUIT to my child process") | 1471 log("mx: implement me! want to send SIGQUIT to my child process") |
1472 else: | 1472 else: |
1478 Aborts the program with a SystemExit exception. | 1478 Aborts the program with a SystemExit exception. |
1479 If 'codeOrMessage' is a plain integer, it specifies the system exit status; | 1479 If 'codeOrMessage' is a plain integer, it specifies the system exit status; |
1480 if it is None, the exit status is zero; if it has another type (such as a string), | 1480 if it is None, the exit status is zero; if it has another type (such as a string), |
1481 the object's value is printed and the exit status is one. | 1481 the object's value is printed and the exit status is one. |
1482 """ | 1482 """ |
1483 | |
1484 if _opts.killwithsigquit: | |
1485 _send_sigquit() | |
1483 | 1486 |
1484 # import traceback | 1487 # import traceback |
1485 # traceback.print_stack() | 1488 # traceback.print_stack() |
1486 p, _ = _currentSubprocess | 1489 p, _ = _currentSubprocess |
1487 if p is not None: | 1490 if p is not None: |
4074 c, _ = _commands[command][:2] | 4077 c, _ = _commands[command][:2] |
4075 def term_handler(signum, frame): | 4078 def term_handler(signum, frame): |
4076 abort(1) | 4079 abort(1) |
4077 signal.signal(signal.SIGTERM, term_handler) | 4080 signal.signal(signal.SIGTERM, term_handler) |
4078 | 4081 |
4082 def quit_handler(signum, frame): | |
4083 _send_sigquit() | |
4079 signal.signal(signal.SIGQUIT, quit_handler) | 4084 signal.signal(signal.SIGQUIT, quit_handler) |
4080 | 4085 |
4081 try: | 4086 try: |
4082 if opts.timeout != 0: | 4087 if opts.timeout != 0: |
4083 def alarm_handler(signum, frame): | 4088 def alarm_handler(signum, frame): |