From a17360d02392f4c92d5736d76877193b62b68c14 Mon Sep 17 00:00:00 2001 From: Andy C Date: Wed, 2 Feb 2022 21:25:15 -0500 Subject: [PATCH] [interactive] Fix wait exit code if interrupted by Ctrl-C It should be 130. This involved just removing the KeyboardInterrupt clause in WaitForOne(). I ran 'git blame' on that KeyboardInterrupt line, which led me to ff36fe6d11fdda3bffd0cc1c524cae7103d9a77b from June 2019. I tested with spec/stateful/ctrl-c.sh, and neither case has a problem without it. (Actually process-loop seems to behave a little better interactively? It's easier to cancel.) And this makes the last case in spec/stateful PASS. --- core/process.py | 12 ------------ test/stateful.sh | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/core/process.py b/core/process.py index 11b5b642de..469eac4027 100644 --- a/core/process.py +++ b/core/process.py @@ -1440,18 +1440,6 @@ def WaitForOne(self): else: # The signature of waitpid() means this shouldn't happen raise AssertionError() - except KeyboardInterrupt: - # NOTE: Another way to handle this is to disable SIGINT when a process is - # running. Not sure if there's any real difference. bash and dash - # handle SIGINT pretty differently. - if self.exec_opts.interactive(): - # TODO: fix status=130 bug here - # Caller should keep waiting. If we run 'sleep 3' and hit Ctrl-C, both - # processes will get SIGINT, but the shell has to wait again to get the - # exit code. - return W1_OK - else: - raise # abort a batch script # All child processes are supposed to be in this dict. But this may # legitimately happen if a grandchild outlives the child (its parent). diff --git a/test/stateful.sh b/test/stateful.sh index 75350e5cf5..a7b2a2029b 100755 --- a/test/stateful.sh +++ b/test/stateful.sh @@ -27,7 +27,7 @@ export PYTHONPATH=. readonly BASE_DIR=_tmp/stateful signals() { - spec/stateful/signals.py --osh-failures-allowed 1 \ + spec/stateful/signals.py \ $OSH bash "$@" }