Skip to content

Commit

Permalink
[interactive] Fix wait exit code if interrupted by Ctrl-C
Browse files Browse the repository at this point in the history
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

ff36fe6

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.
  • Loading branch information
Andy C committed Feb 3, 2022
1 parent c1900bf commit a17360d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
12 changes: 0 additions & 12 deletions core/process.py
Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion test/stateful.sh
Expand Up @@ -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 "$@"
}

Expand Down

0 comments on commit a17360d

Please sign in to comment.