kill(1) — Commands
OSF
NAME
kill − Sends a signal to a running process
SYNOPSIS
kill [-signal_name | -signal_number] process_ID ...
kill -l
The kill command sends a signal to one or more running processes, by default the SIGTERM signal (signal number 15).
FLAGS
-signal_name
-signal_number
Specifies the signal to send to the process. You can specify either a name, stripped of the SIG prefix (such as KILL), or a number (such as 9). For information about signal names and numbers, see the sigaction() system call.
-lLists signal names in numerical order (as given in the /usr/include/signal.h file).
DESCRIPTION
SIGTERM normally terminates processes that do not ignore or catch the signal.
Specify the processes to be signaled by giving their process identification numbers (also known as process IDs or PIDs). The shell reports the PID of each process that is running in the background (unless you start more than one process in a pipeline, in which case the shell reports the number of the last process). You can also use the ps command to find the process ID of commands.
Specify the signal to send with -signal_name or -signal_number. In particular, SIGKILL (9) terminates all running processes, including those not terminated by the default SIGTERM. (For a list of signal numbers, see the sigaction() system call.) Note that you can specify signal names with or without the SIG prefix.
Unless you are are operating with superuser authority, the process you wish to signal must belong to you. When operating with superuser authority, you can signal any process.
See the kill() system call for a complete discussion of kill. (Note that the csh command contains a built-in subcommand named kill, but the command and subcommand do not necessarily work in the same way. For information on the subcommand, see csh.)
Special Process IDs
There are several special process IDs you can specify to cause the following special actions:
0The signal is sent to all processes having a process group ID equal to the process group ID of the sender, except those with PIDs 0 and 1.
-1If the effective user ID of the sender is not 0 (root), the signal is sent to all processes with a process group ID equal to the effective user ID of the sender, except those with PIDs 0 and 1. If the effective user ID of the sender is 0 (root), the signal is sent to all processes, excluding numbers 0 and 1.
-PIDThe signal is sent to all processes whose process group number is equal to the absolute value of PID.
Note that when you specify any negative PID, you must also specify the signal to be sent, even the default signal SIGTERM.
EXAMPLES
1.To terminate a given process, enter:
kill 1095
This terminates process 1095 by sending it the default SIGTERM signal. Note that process 1095 might not actually terminate if it has made special arrangements to ignore or catch the SIGTERM signal.
2.To terminate several processes that ignore the default signal, enter:
kill -9 17285 15692
This sends SIGKILL to processes 17285 and 15692. SIGKILL is a special signal that normally cannot be ignored or caught.
3.To terminate all of your background processes, enter:
kill 0
This sends the SIGTERM signal to all members of the shell process group. This includes all background processes started with &. Although the signal is sent to the shell, it has no effect because the shell ignores the default signal 15.
4.To terminate all your processes and log yourself out, enter:
kill -9 0
This sends SIGKILL to all members of the shell process group. Because the shell cannot ignore SIGKILL, this also terminates the login shell and logs you out. If you are using multiple windows, this closes the active window.
5.To terminate all processes that you own, enter:
kill -9 -1
This sends SIGKILL to all processes owned by you, even those started at other systems and that belong to other process groups. If you are using multiple windows, this closes all the windows. If you have outstanding print requests, they are also terminated.
6.To send the default signal 15 with a negative PID such as -1, you must specify -15 (-SIGTERM) explicitly, enter:
kill -15 -1
7.To send a different signal to a process, enter:
kill -16 1103
This sends the SIGUSR1 signal to process 1103. The action taken on the SIGUSR1 signal is defined by the particular application you are running. (The name of the kill command is misleading because many signals, including SIGUSR1, do not terminate processes.)
8.To list the signal names in numerical order, stripped of the SIG prefix, enter:
kill -l
This results in the following:
1: SIGHUP9: SIGKILL17: SIGSTOP25: SIGXFSZ
2: SIGINT10: SIGBUS18: SIGTSTP26: SIGVTALRM
3: SIGQUIT11: SIGSEGV19: SIGCONT27: SIGPROF
4: SIGILL12: SIGSYS20: SIGCHLD28: SIGWINCH
5: SIGTRAP13: SIGPIPE21: SIGTTIN30: SIGUSR1
6: SIGIOT14: SIGALRM22: SIGTTOU31: SIGUSR2
7: SIGEMT15: SIGTERM23: SIGIO
8: SIGFPE16: SIGURG24: SIGXCPU
This list may vary from system to system.
FILES
/usr/include/signal.hSpecifies signal names.
RELATED INFORMATION
Commands: csh(1), killall(8), ksh(1), ps(1), sh(1).
Functions: kill(2), sigaction(2).