From f945ef8ee8f51b55e8b96ea555ea5490dcf295c6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 16 Oct 2022 15:32:12 +0530 Subject: [PATCH] handle ctrl-c better when interrupting go test --- kitty_tests/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kitty_tests/main.py b/kitty_tests/main.py index 3eddfdf3f..0c26f9b31 100644 --- a/kitty_tests/main.py +++ b/kitty_tests/main.py @@ -158,7 +158,12 @@ def run_python_tests(args: Any, go_proc: 'Optional[subprocess.Popen[bytes]]' = N tests = find_all_tests() def print_go() -> None: - print(go_proc.stdout.read().decode(), end='', flush=True) + try: + print(go_proc.stdout.read().decode(), end='', flush=True) + except KeyboardInterrupt: + go_proc.terminate() + if go_proc.wait(0.1) is None: + go_proc.kill() go_proc.stdout.close() go_proc.wait()