If I understand Gilles' answer What causes various signals to be sent? correctly, there are several signals related to job control by a shell process running in a terminal:
key press notifications: SIGINT, SIGQUIT, SIGTSTP
SIGSTOP, SIGCHLD, SIGCONT,
SIGTTIN and SIGTTOU
SIGWINCH and SIGHUP.
I was wondering which terminal related signals are sent to the child processes of the shell directly without reaching the shell process in the terminal first, and which are sent to the shell process in the terminal first and let the shell resend to its child processes?
For example for two signals that are most often used, are the followings correct?
SIGHUP is sent first to the shell process, which then resend it to all the child processes of the shell, whether they are in foreground or background (that is when nohup
can make difference).
Which one is correct for SIGINT when pressing Ctrl-C:
Terminal driver sends SIGINT only to the processes in the foreground group, but not to the parent shell process running in the terminal. so the parent shell process never needs to handle SIGINT.
Terminal driver sends SIGINT to the shell process running in the terminal, and the shell process handles SIGINT by resending SIGINT to the processes in the foreground group.
If I understand Stéphane Chazelas's reply https://unix.stackexchange.com/a/384702/674 correctly, is the first one correct?
Thanks!
SIGINT
involved. – JdeBP Feb 16 '19 at 09:36^C
is independent ofICANON
. You need to disableISIG
for it to stop, and most shells with advanced line editors like bash, zsh, tcsh, fish don't and do rely on SIGINT being sent on^C
(can also be used to let users kill runaway completion widgets for instance). – Stéphane Chazelas Feb 17 '19 at 14:45