1

When the shell is not running any process, if I press Ctrl+C on the terminal, the shell will not terminate. Is this simply because the shell ignores the SIGINT signal, or is there another reason?

2

The shell ignores ctrl-C so that other programs that the shell is running can catch it. An EOF on a blank line exits (ctrl-D in *nix, ctrl-Z in Windows).

  • You mean if a process ignores the SIGINT signal, then this signal will go to its child process? – Steve May 16 '17 at 18:37
  • @Steve I think it is specific to interactive shell sessions. The shell is an interpreter, so anything you type is going through the shell to your program. The shell delivers keyboard interrupts intact, because in an interactive environment, programs may be expecting them, but in any other environment they won't. – dogoncouch May 16 '17 at 22:43
  • No, I don't think anything goes through the shell, for example if the shell executed the cat program, then anything I type into the terminal is going directly to the cat program without going through the shell first (Assuming you mean by "shel" programs like bash and sh). – Steve May 16 '17 at 22:49

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