SIGNALS When bash is interactive, in the absence of any traps, it ignores SIGTERM (so that kill 0 does not kill an interactive shell), and SIGINT is caught and handled (so that the wait builtin is interruptible). In all cases, bash ignores SIGQUIT. If job control is in effect, bash ig‐ nores SIGTTIN, SIGTTOU, and SIGTSTP. Non-builtin commands run by bash have signal handlers set to the values inherited by the shell from its parent. When job control is not in ef‐ fect, asynchronous commands ignore SIGINT and SIGQUIT in addition to these inherited handlers. Commands run as a result of command substi‐ tution ignore the keyboard-generated job control signals SIGTTIN, SIGT‐ TOU, and SIGTSTP. The shell exits by default upon receipt of a SIGHUP. Before exiting, an interactive shell resends the SIGHUP to all jobs, running or stopped. Stopped jobs are sent SIGCONT to ensure that they receive the SIGHUP. To prevent the shell from sending the signal to a particular job, it should be removed from the jobs table with the disown builtin (see SHELL BUILTIN COMMANDS below) or marked to not receive SIGHUP us‐ ing disown -h. If the huponexit shell option has been set with shopt, bash sends a SIGHUP to all jobs when an interactive login shell exits. If bash is waiting for a command to complete and receives a signal for which a trap has been set, the trap will not be executed until the com‐ mand completes. When bash is waiting for an asynchronous command via the wait builtin, the reception of a signal for which a trap has been set will cause the wait builtin to return immediately with an exit sta‐ tus greater than 128, immediately after which the trap is executed. When job control is not enabled, and bash is waiting for a foreground command to complete, the shell receives keyboard-generated signals such as SIGINT (usually generated by ^C) that users commonly intend to send to that command. This happens because the shell and the command are in the same process group as the terminal, and ^C sends SIGINT to all pro‐ cesses in that process group. When bash is running without job control enabled and receives SIGINT while waiting for a foreground command, it waits until that foreground command terminates and then decides what to do about the SIGINT: 1. If the command terminates due to the SIGINT, bash concludes that the user meant to end the entire script, and acts on the SIGINT (e.g., by running a SIGINT trap or exiting itself); 2. If the command does not terminate due to SIGINT, the program handled the SIGINT itself and did not treat it as a fatal sig‐ nal. In that case, bash does not treat SIGINT as a fatal sig‐ nal, either, instead assuming that the SIGINT was used as part of the program's normal operation (e.g., emacs uses it to abort editing commands) or deliberately discarded. However, bash will run any trap set on SIGINT, as it does with any other trapped signal it receives while it is waiting for the foreground com‐ mand to complete, for compatibility.