Search code examples
linuxbashsignals

Sending SIGINT from keyboard to piped commands in bash


If in bash I run a | b | c | d on the command line and then press ^C, which process gets the signal?


Solution

  • In short, they all do.

    When setting up a pipeline, the shell creates a process group. ^C is interpreted by the kernel's line discipline as the user's request to interrupt the process group currently running in the foreground. Sending a signal such as SIGINT to a process group automatically delivers the signal to all processes in the group.