From bash manual

When Bash receives a SIGINT, it breaks out of any executing loops.

When receiving SIGINT, does bash also quit other commands, besides loops (for or while)? Thanks.

1 Answer 1


Quoting the bash manual:

When bash is interactive, in the absence of any traps, it ignores SIGTERM (so that kill 0 does not kill an interactive shell), and SIGINT is caught and handled (so that the wait builtin is interruptible).

Yes, bash quits builtins when it receives SIGINT. You can verify that with wait or read (read from a large file with no newlines will give you time to press CtrlC). wait in particular needs to deal with SIGINT correctly, as per POSIX (along with all other signals it can come across).

  • Thanks. Besides loop and builtins, does bash quit anything else?
    – Tim
    May 28, 2018 at 11:39
  • What else could it quit? May 28, 2018 at 13:07
  • like other control flow contructs such as "if" and external commands? Why are they not mentioned?
    – Tim
    May 28, 2018 at 13:14
  • External commands deal with SIGINT themselves (the shell is informed if an external command was killed by a signal, but it deals with that by interpreting the information given by wait(2) or waitpid(2), not by installing a signal handler). if etc. run at a point in time, so there’s not much point in making them interruptible. May 28, 2018 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.