Chromium Code Reviews| Index: tools/testing/drt-trampoline.py |
| diff --git a/tools/testing/drt-trampoline.py b/tools/testing/drt-trampoline.py |
| index ac5b23d690af3de4017eebf27fa14da8ecb55ada..6f8dde36796b2c67c6e1109fec560d4f35ca2b61 100644 |
| --- a/tools/testing/drt-trampoline.py |
| +++ b/tools/testing/drt-trampoline.py |
| @@ -89,13 +89,25 @@ def main(argv): |
| p.terminate() |
| sys.exit(0) |
| - # SIGINT is Ctrl-C. |
| - signal.signal(signal.SIGINT, signal_handler) |
| - # SIGTERM is sent by test.dart when a process times out. |
| - signal.signal(signal.SIGTERM, signal_handler) |
| - output, error = p.communicate() |
| - signal.signal(signal.SIGINT, signal.SIG_DFL) |
| - signal.signal(signal.SIGTERM, signal.SIG_DFL) |
| + def windows_exit_handler(signal): |
| + p.terminate() |
| + sys.exit(0) |
| + |
| + if os.name == 'nt' |
| + try: |
| + import win32api |
| + win32api.SetConsoleCtrlHandler(windows_exit_handler, True) |
| + except ImportError: |
| + version = ".".join(map(str, sys.version_info[:2])) |
|
kustermann
2012/12/13 14:10:02
I think "str" is not defined here
kustermann
2012/12/13 14:11:06
Sorry, I forgot that it's in the builtins.
|
| + raise Exception("pywin32 not installed for Python " + version) |
| + else: |
| + # SIGINT is Ctrl-C. |
| + signal.signal(signal.SIGINT, signal_handler) |
| + # SIGTERM is sent by test.dart when a process times out. |
| + signal.signal(signal.SIGTERM, signal_handler) |
| + output, error = p.communicate() |
| + signal.signal(signal.SIGINT, signal.SIG_DFL) |
| + signal.signal(signal.SIGTERM, signal.SIG_DFL) |
| if p.returncode != 0: |
| raise Exception('Failed to run command. return code=%s' % p.returncode) |