Sends a signal to running processes.
To Send Signal to Processes
kill [ -s { SignalName | SignalNumber } ] ProcessID ...
kill [ - SignalName | - SignalNumber ] ProcessID ...
To List Signal Names
kill -l [ ExitStatus ]
The kill command sends a signal (by default, the SIGTERM signal) to a running process. This default action normally stops processes. If you want to stop a process, specify the process ID (PID) in the ProcessID variable. 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 number of commands.
A root user can stop any process with the kill command. If you are not a root user, you must have initiated the process you want to stop.
SignalName is recognized in a case-independent fashion, without the SIG prefix.
If the specified SignalNumber is 0, the kill command checks the validity of the specified PID.
Item | Description |
---|---|
-s{SignalName | SignalNumber} | Specifies the signal as a signal number or a signal name, such as -9 or KILL for the SIGKILL signal. |
-SignalName | Specifies a signal name, such as SIGHUP. |
-SignalNumber | Specifies a signal number. Note: To specify the negative PID with the default signal in this syntax, you must specify - - as a signal. Otherwise the first operand is interpreted as a SignalNumber. |
ProcessID | Specifies a decimal integer representing a process or process group to be signaled. If PID is a positive value, the kill command sends the process whose process ID is equal to the PID. If the PID value is 0, the kill command sends the signal to all processes having a process group ID equal to the process group ID of the sender. The signal is not sent to processes with a PID of 0 or 1. If the PID is -1, the kill command sends the signal to all processes owned by the effective user of the sender. The signal is not sent to processes with a PID of 0 or 1. If it is a negative number but not -1, the kill command sends the signal to all processes that have a process group ID equal to the absolute value of the PID. |
-l | Lists all signal names supported by the implementation |
-lExitStatus | Lists signal names stripped of the common SIG prefix. If ExitStatus is an decimal integer value, the signal name corresponding to that signal is displayed. If ExitStatus is a value of the exit status corresponding to a process that was terminated by a signal, the signal name corresponding to the signal that terminated the process is displayed. |
This command returns the following exit values:
Item | Description |
---|---|
0 | At least one matching process was found for each ProcessID operand, and the specified signal was successfully processed for at least one matching process. |
>0 | An error occurred. |
kill 1095
This stops
process 1095 by sending it the default SIGTERM signal.
Note that process 1095 might not actually stop if it has
made special arrangements to ignore or override the SIGTERM signal.kill -kill 2098 1569
This
sends signal 9, the SIGKILL signal, to processes 2098 and 1569.
The SIGKILL signal is a special signal that normally cannot
be ignored or overridden.kill -kill 0
This
sends signal 9, the SIGKILL signal, to all processes having
a process group ID equal to the senders process group ID. Because
the shell cannot ignore the SIGKILL signal, this also stops
the login shell and logs you off.kill -9 -1
This
sends signal 9, the SIGKILL signal, to all processes owned
by the effective user, even those started at other work stations and
that belong to other process groups. If a listing that you requested
is being printed, it is also stopped.kill -USR1 1103
The
name of the kill command is misleading because many signals,
including SIGUSR1, do not stop processes. The action taken
on SIGUSR1 is defined by the particular application you are
running.Note: To send signal 15, the SIGTERM signal with this form of the kill command, you must explicitly specify -15 or TERM.
Item | Description |
---|---|
/usr/include/sys/signal.h | Specifies signal names. |