Section (1) kill
kill — terminate a process
− signal |
−s signal |
−p ] [
−q value ] [
−−] pid | name...
−l [number] |
The command kill sends the specified
signal to the
specified processes or process groups.
If no signal is specified, the TERM signal is sent. The default action for this signal is to terminate the process. This signal should be used in preference to the KILL signal (number 9), since a process may install a handler for the TERM signal in order to perform clean-up steps before terminating in an orderly fashion. If a process does not terminate after a TERM signal has been sent, then the KILL signal may be used; be aware that the latter signal cannot be caught, and so does not give the target process the opportunity to perform any clean-up before terminating.
Most modern shells have a builtin kill command, with a
usage rather similar to that of the command described here.
−−queue options, and
the possibility to specify processes by command name, are
signal is 0,
then no actual signal is sent, but error checking is still
The list of processes to be signaled can be a mixture of names and PIDs.
pidcan be one of four things:
nis larger than 0. The process with PID
All processes in the current process group are signaled.
All processes with a PID larger than 1 are signaled.
nis larger than 1. All processes in process group
nare signaled. When an argument of the form _zsingle_quotesz_-n_zsingle_quotesz_ is given, and it is meant to denote a process group, either a signal must be specified first, or the argument must be preceded by a _zsingle_quotesz_--_zsingle_quotesz_ option, otherwise it will be taken as the signal to send.
All processes invoked using this
namewill be signaled.
The signal to send. It may be given as a name or a number.
Print a list of signal names, or convert the given signal number to a name. The signals can be found in
−l, but it will print signal names and their corresponding numbers.
Do not restrict the command-name-to-PID conversion to processes with the same UID as the present process.
Only print the process ID (PID) of the named processes, do not send any signals.
Print PID(s) that will be signaled with kill along with the signal.
Use sigqueue(3) rather than kill(2). The
valueargument is an integer that is sent along with the signal. If the receiving process has installed a handler for this signal using the
SA_SIGINFOflag to sigaction(2), then it can obtain this data via the si_sigval field of the siginfo_t structure.
Although it is possible to specify the TID (thread ID, see
gettid(2)) of one of the
threads in a multithreaded process as the argument of
signal is nevertheless directed to the process (i.e., the
entire thread group). In other words, it is not possible to
send a signal to an explicitly selected thread in a
multithreaded process. The signal will be delivered to an
arbitrarily selected thread in the target process that is not
blocking the signal. For more details, see signal(7) and the
kill has the following return codes:
partial success (when more than one process specified)
The kill command is part of the util-linux package and is available from Linux Kernel Archive
Copyright 1994 Salvatore Valente (svalentemit.edu)
Copyright 1992 Rickard E. Faith (faithcs.unc.edu)
May be distributed under the GNU General Public License
Section (2) kill
kill — send signal to a process
#include <sys/types.h> #include <signal.h>
kill() system call can
be used to send any signal to any process group or
positive, then signal
sig is sent to the process with
the ID specified by
pid equals 0,
sig is sent to
every process in the process group of the calling
sent to every process for which the calling process has
permission to send signals, except for process 1 (
init), but see below.
pid is less
than −1, then
sig is sent to every process in
the process group whose ID is
sig is 0, then
no signal is sent, but existence and permission checks are
still performed; this can be used to check for the existence
of a process ID or process group ID that the caller is
permitted to signal.
For a process to have permission to send a signal, it must
either be privileged (under Linux: have the
CAP_KILL capability in the user namespace
of the target process), or the real or effective user ID of
the sending process must equal the real or saved set-user-ID
of the target process. In the case of
SIGCONT, it suffices when the sending and
receiving processes belong to the same session.
(Historically, the rules were different; see NOTES.)
On success (at least one signal was sent), zero is
returned. On error, −1 is returned, and
errno is set appropriately.
An invalid signal was specified.
The calling process does not have permission to send the signal to any of the target processes.
The target process or process group does not exist. Note that an existing process might be a zombie, a process that has terminated execution, but has not yet been wait(2)ed for.
The only signals that can be sent to process ID 1, the
init process, are
those for which
init has explicitly installed
signal handlers. This is done to assure the system is not
brought down accidentally.
POSIX.1 requires that
sig to all processes
that the calling process may send signals to, except possibly
for some implementation-defined system processes. Linux
allows a process to signal itself, but on Linux the call
does not signal the calling process.
POSIX.1 requires that if a process sends a signal to
itself, and the sending thread does not have the signal
blocked, and no other thread has it unblocked or is waiting
for it in sigwait(3), at least one
unblocked signal must be delivered to the sending thread
Across different kernel versions, Linux has enforced different rules for the permissions required for an unprivileged process to send a signal to another process. In kernels 1.0 to 1.2.2, a signal could be sent if the effective user ID of the sender matched effective user ID of the target, or the real user ID of the sender matched the real user ID of the target. From kernel 1.2.3 until 1.3.77, a signal could be sent if the effective user ID of the sender matched either the real or effective user ID of the target. The current rules, which conform to POSIX.1, were adopted in kernel 1.3.78.
In 2.6 kernels up to and including 2.6.7, there was a bug
that meant that when sending signals to a process group,
kill() failed with the error
EPERM if the caller did not
have permission to send the signal to
any (rather than
all) of the members of the
process group. Notwithstanding this error return, the signal
was still delivered to all of the processes for which the
caller had permission to signal.
This page is part of release 5.04 of the Linux
man-pages project. A
description of the project, information about reporting bugs,
and the latest version of this page, can be found at
Copyright (c) 1992 Drew Eckhardt (drewcs.colorado.edu), March 28, 1992
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the
entire resulting derived work is distributed under the terms of a
permission notice identical to this one.
Since the Linux kernel and libraries are constantly changing, this
manual page may be incorrect or out-of-date. The author(s) assume no
responsibility for errors or omissions, or for damages resulting from
the use of the information contained herein. The author(s) may not
have taken the same level of care in the production of this manual,
which is licensed free of charge, as they might when working
Formatted or processed versions of this manual, if unaccompanied by
the source, must acknowledge the copyright and authors of this work.
Modified by Michael Haardt <michaelmoria.de>
Modified by Thomas Koenig <ig25rz.uni-karlsruhe.de>
Modified 1993-07-23 by Rik Faith <faithcs.unc.edu>
Modified 1993-07-25 by Rik Faith <faithcs.unc.edu>
Modified 1995-11-01 by Michael Haardt
Modified 1996-04-14 by Andries Brouwer <aebcwi.nl>
[added some polishing contributed by Mike Battersby <mibdeakin.edu.au>]
Modified 1996-07-21 by Andries Brouwer <aebcwi.nl>
Modified 1997-01-17 by Andries Brouwer <aebcwi.nl>
Modified 2001-12-18 by Andries Brouwer <aebcwi.nl>
Modified 2002-07-24 by Michael Kerrisk <mtk.manpagesgmail.com>
Added note on historical rules enforced when an unprivileged process
sends a signal.
Modified 2004-06-16 by Michael Kerrisk <mtk.manpagesgmail.com>
Added note on CAP_KILL
Modified 2004-06-24 by aeb
Modified, 2004-11-30, after idea from emmanuel.colbusensimag.imag.fr