Your system contains a man page listing all the available signals, but depending on your operating system, it might be opened in a different way. On most Linux systems, this will be man 7 signal. When in doubt, locate the exact man page and section using commands like
man -k signal | grep list
apropos signal | grep list
Signal names can be found using kill -l.
In the absence of any traps, an interactive Bash shell ignores SIGTERM and SIGQUIT. SIGINT is caught and handled, and if job control is active, SIGTTIN, SIGTTOU and SIGTSTP are also ignored. Commands that are run as the result of a command substitution also ignore these signals, when keyboard generated.
SIGHUP by default exits a shell. An interactive shell will send a SIGHUP to all jobs, running or stopped; see the documentation on the disown built-in if you want to disable this default behavior for a particular process. Use the huponexit option for killing all jobs upon receiving a SIGHUP signal, using the shopt built-in.
The following signals can be sent using the Bash shell:
Table 12-1. Control signals in Bash
Most modern shells, Bash included, have a built-in kill function. In Bash, both signal names and numbers are accepted as options, and arguments may be job or process IDs. An exit status can be reported using the -l option: zero when at least one signal was successfully sent, non-zero if an error occurred.
Using the kill command from /usr/bin, your system might enable extra options, such as the ability to kill processes from other than your own user ID and specifying processes by name, like with pgrep and pkill.
Both kill commands send the TERM signal if none is given.
This is a list of the most common signals:
Table 12-2. Common kill signals
When killing a process or series of processes, it is common sense to start trying with the least dangerous signal, SIGTERM. If that does not work, use the INT orKILL signals. For instance, when a process does not die using Ctrl+C, it is best to use the kill -9 on that process ID:
maud: ~> ps -ef | grep stuck_process maud 5607 2214 0 20:05 pts/5 00:00:02 stuck_process maud: ~> kill -9 5607 maud: ~> ps -ef | grep stuck_process maud 5614 2214 0 20:15 pts/5 00:00:00 grep stuck_process + Killed stuck_process
When a process starts up several instances, killall might be easier. It takes the same option as the kill command, but applies on all instances of a given process. Test this command before using it in a production environment, since it might not work as expected on some of the commercial Unices.
Meet new people