Contents
When to send SIGINT to foreground process group?
The POSIX specification says that when INTR is received, it should send a SIGINT to the foreground process group of that terminal. What is the foreground process group?
How to send a signal SIGINT from script?
Background processes are those whose process group ID differs from the terminal’s; such processes are immune to keyboard-generated signals. I have found that if you trap and kill using another signal such as SIGUSR1 it works. Non-builtin commands run by bash have signal handlers set to the values inherited by the shell from its parent.
Why is a SIGINT ignored in a script?
My hypothesis is that since the script is running from a non-interactive shell (as a child of a script) that SIGINT, which is a keyboard signal, is ignored. Background processes are those whose process group ID differs from the terminal’s; such processes are immune to keyboard-generated signals.
When does TTY send a SIGINT to the foreground process?
When you press CTRL + C, your terminal emulator sends an ETX character (end-of-text / 0x03). The TTY is configured such that when it receives this character, it sends a SIGINT to the foreground process group of the terminal.
How are signals sent to processes in process group 12345?
When you type a signal-generating key sequence (e.g., Ctrl + C ), the signal is sent to all processes that are attached to (associated with) the terminal. There is no such mechanism for signals generated by kill. will send the signal to all processes in process group 12345; see kill (1) and kill (2) .
How does Ctrl + C send a SIGINT?
The first thing is to understand how CTRL + C works. When you press CTRL + C, your terminal emulator sends an ETX character (end-of-text / 0x03). The TTY is configured such that when it receives this character, it sends a SIGINT to the foreground process group of the terminal.