Foreground terminal
Every terminal has an associated “foreground” process group ID. When you type CTRL-C
, your terminal sends a signal to every process inside the foreground process group. You can change which process group is in the foreground of a terminal with tcsetpgrp(int fd, pid_t pgrp)
. The fd
should be 0 for “standard input”.