Handling Signals
Linux uses signals to communicate with processes running on the system. Chapter 4 described the different Linux signals and how the Linux system uses these signals to stop, start, and kill processes. You can control the operation of your shell script by programming the script to perform certain commands when it receives specific signals.
Signaling the bash shell
There are more than 30 Linux signals that can be generated by the system and applications. Table 16.1 lists the most common Linux system signals that you'll run across in your shell script writing.
Table 16.1 Linux Signals
Signal | Value | Description | ||
1 |
SIGHUP |
Hangs up the process | ||
2 |
SIGINT |
Interrupts the process | ||
3 |
SIGQUIT |
Stops the process | ||
9 |
SIGKILL |
Unconditionally terminates the process | ||
15 |
SIGTERM |
Terminates the process if possible | ||
17 |
SIGSTOP |
Unconditionally stops, but doesn't terminate, the process | ||
18 |
SIGTSTP |
Stops or pauses the process, but doesn't terminate... |