Common Signals
| Number | Name | Meaning |
|---|---|---|
| 1 | HUP | Hang up. This is a vestige of the good old days when terminals were attached to remote computers with phone lin and modems. The signal is used to indicate to programs that the controlling terminal has “hung up.” The effect of this signal can be demonstrated by closing a terminal session. The foreground program running on the terminal will be sent the signal and will terminate. This signal is also used by many daemon programs to cause a reinitialization. This means that when a daemon is sent this signal, it will restart and reread its configuration file. The Apache web server is an example of a daemon that uses the HUP signal in this way. |
| 2 | INT | Interrupt. This performs the same function as ctrl-C sent from the terminal. It will usually terminate a program |
| 9 | KILL | Kill. This signal is special. Whereas programs may choose to handle signals sent to them in different ways, including ignoring them all togher, the KILL signal is never actually sent to the target program. Rather, the kernel immediately terminates the process. When a process is terminated in this manner, it is given no opportunity to “clean u” after itself or save its work. For this reason, the KILL signal should be used only as a last resort when other termination signals fail. |
| 15 | TERM | Terminate. This is the default signal sent by the kill command. If a program is still “alive” enough to receive gnals, it will terminate. |
| 18 | CONT | Continue. This will restore a process after a STOP or TSTP signal. This signal is sent by the bg and fg commands |
| 19 | STOP | Stop. This signal causes a process to pause without terminating. Like the KILL signal, it is not sent to the target process, and thus it cannot be ignored |
| 20 | TSTP | Terminal stop. This is the signal sent by the terminal when ctrl-Z is pressed. Unlike the STOP signal, the TSTP signal is received by the program, but the program may choose to ignore it. |
| The following signals frequently used by the system. | ||
| 3 | QUIT | Quit. |
| 11 | SEGV | Segmentation violation. This signal is sent if a program makes illegal use of memory; that is, if it tried to write somewhere it was not allowed to write. |
| 28 | WINCH | Window change. This is the signal sent by the system when a window changes size. Some programs, such as top and less, will respond to this signal by redrawing themselves to fit the new window dimensions. |
kill: Sending Signals to Processes
Options & Arguments
kill [l|L]kill [-<signal>|-s <signal>|--signal <signal>] [<pid>|<jobspec>]...
- 如果 signal 没有指定,默认为 15 TERM
- Negative PID values may be used to choose whole process groups; see the PGID column in
ps jcommand output. - A PID of -1 is special; it indicates all processes except the kill process itself and init.
- You must be the owner of a process (or the superuser) to send it signals with
kill. | Option | Long Option | Description | | —- | —- | —- | | -
-s| —signal | Specify the signal to be sent.
Alternate signals may be specified in three ways:
- -9 number
- -SIGKILL name
- -KILL name prefixed with SIG
| | -l, —list [signal] | | List signal names.
This option has optional argument, which will convert signal number to signal name, or other way around. |
NOTES Your shell (command line interpreter) may have a built-in kill command. You may need to run the command described here as /bin/kill to solve the conflict.
Examples
kill -9 -1
Kill all processes you can kill.kill -l 11
Translate number 11 into a signal name.kill -L
List the available signal choices in a nice table.kill 123 543 2341 3453
Send the default signal, SIGTERM, to all those processes.
killall: Kill Processes by Name
Options & Arguments
killall [-u user] [-signal] name...
- You must be the owner of a process (or the superuser) to send it signals with
killall. | Option | Long Option | Description | | —- | —- | —- | | -
-s| —signal | As with kill. | | -u | —user | Kill only processes the specified user owns.
Command names are optional. | | -l | —list | List all known signal names. |
