diff options
author | Josh Matthews <josh@joshmatthews.net> | 2016-06-17 10:44:45 +0100 |
---|---|---|
committer | Josh Matthews <josh@joshmatthews.net> | 2016-06-17 10:45:54 +0100 |
commit | 342ccafe9206ad7ad1e586452c9d7376fb7a8885 (patch) | |
tree | 3a1cc17e31b39e963242714cef4362609f02cd72 /python/servo/command_base.py | |
parent | 4f1837e9abd441849f8841a4fab6cb2630e46e2f (diff) | |
download | servo-342ccafe9206ad7ad1e586452c9d7376fb7a8885.tar.gz servo-342ccafe9206ad7ad1e586452c9d7376fb7a8885.zip |
Pass Ctr+C to underlying process when invoking commands through mach.
Diffstat (limited to 'python/servo/command_base.py')
-rw-r--r-- | python/servo/command_base.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 66c4a0caa17..e90245f43ec 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -102,7 +102,20 @@ def check_call(*args, **kwargs): print(' '.join(args[0])) # we have to use shell=True in order to get PATH handling # when looking for the binary on Windows - return subprocess.check_call(*args, shell=sys.platform == 'win32', **kwargs) + proc = subprocess.Popen(*args, shell=sys.platform == 'win32', **kwargs) + status = None + # Leave it to the subprocess to handle Ctrl+C. If it terminates as + # a result of Ctrl+C, proc.wait() will return a status code, and, + # we get out of the loop. If it doesn't, like e.g. gdb, we continue + # waiting. + while status is None: + try: + status = proc.wait() + except KeyboardInterrupt: + pass + + if status: + raise subprocess.CalledProcessError(status, ' '.join(*args)) def is_windows(): |