kill (1p) - Linux Manuals
kill: terminate or signal processes
PROLOG
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.NAME
kill - terminate or signal processes
SYNOPSIS
kill -s signal_name pid ...
kill -l [exit_status]
kill [-signal_name] pid ...
DESCRIPTION
The kill utility shall send a signal to the process or processes specified by each pid operand.
For each pid operand, the kill utility shall perform actions equivalent to the kill() function defined in the System Interfaces volume of IEEE Std 1003.1-2001 called with the following arguments:
- *
- The value of the pid operand shall be used as the pid argument.
- *
- The sig argument is the value specified by the -s option, - signal_number option, or the - signal_name option, or by SIGTERM, if none of these options is specified.
OPTIONS
The kill utility shall conform to the Base Definitions volume
of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines,
The following options shall be supported:
Specify the signal to send, using one of the symbolic names defined
in the <signal.h> header. Values of signal_name shall
be recognized in a
case-independent fashion, without the SIG prefix. In addition,
the symbolic name 0 shall be recognized, representing the
signal value zero. The corresponding signal shall be sent instead
of SIGTERM.
Equivalent to -s signal_name.
Specify a non-negative decimal integer, signal_number, representing
the signal to be used instead of SIGTERM, as the
sig argument in the effective call to kill(). The correspondence
between integer
values and the sig value used is shown in the following table.
The effects of specifying any signal_number other than those
listed in the table are undefined.
If the first argument is a negative integer, it shall be interpreted
as a - signal_number option, not as a
negative pid operand specifying a process group.
The following operands shall be supported:
The following environment variables shall affect the execution of
kill:
When the -l option is not specified, the standard output shall
not be used.
When the -l option is specified, the symbolic name of each signal
shall be written in the following format:
where the <signal_name> is in uppercase, without the SIG
prefix, and the <separator> shall be
either a <newline> or a <space>. For the last signal written, <separator>
shall be a <newline>.
When both the -l option and exit_status operand are specified,
the symbolic name of the corresponding signal shall
be written in the following format:
The standard error shall be used only for diagnostic messages.
The following exit values shall be returned:
Default.
The following sections are informative.
Process numbers can be found by using ps.
The job control job ID notation is not required to work as expected
when kill is operating in its own utility execution
environment. In either of the following examples:
the kill operates in a different environment and does not share
the shell's understanding of job numbers.
Any of the commands:
sends the SIGKILL signal to the process whose process ID is 100 and
to all processes whose process group ID is 165, assuming the
sending process has permission to send that signal to the specified
processes, and that they exist.
The System Interfaces volume of IEEE Std 1003.1-2001 and this volume
of IEEE Std 1003.1-2001 do not require
specific signal numbers for any signal_names. Even the -
signal_number option provides symbolic (although
numeric) names for signals. If a process is terminated by a signal,
its exit status indicates the signal that killed it, but the
exact values are not specified. The kill -l option, however,
can be used to map decimal signal numbers and exit
status values into the name of a signal. The following example reports
the status of a terminated job:
To send the default signal to a process group (say 123), an application
should use a command similar to one of the
following:
The -l option originated from the C shell, and is also implemented
in the KornShell. The C shell output can consist of
multiple output lines because the signal names do not always fit on
a single line on some terminal screens. The KornShell output
also included the implementation-defined signal numbers and was considered
by the standard developers to be too difficult for
scripts to parse conveniently. The specified output format is intended
not only to accommodate the historical C shell output, but
also to permit an entirely vertical or entirely horizontal listing
on systems for which this is appropriate.
An early proposal invented the name SIGNULL as a signal_name
for signal 0 (used by the System Interfaces volume of
IEEE Std 1003.1-2001 to test for the existence of a process without
sending it a signal). Since the signal_name 0
can be used in this case unambiguously, SIGNULL has been removed.
An early proposal also required symbolic signal_names to be
recognized with or without the SIG prefix. Historical
versions of kill have not written the SIG prefix for the
-l option and have not recognized the SIG
prefix on signal_names. Since neither applications portability
nor ease-of-use would be improved by requiring this
extension, it is no longer required.
To avoid an ambiguity of an initial negative number argument specifying
either a signal number or a process group,
IEEE Std 1003.1-2001 mandates that it is always considered the former
by implementations that support the XSI option. It
also requires that conforming applications always use the "--"
options terminator argument when specifying a process
group, unless an option is also specified.
The -s option was added in response to international interest
in providing some form of kill that meets the
Utility Syntax Guidelines.
The job control job ID notation is not required to work as expected
when kill is operating in its own utility execution
environment. In either of the following examples:
the kill operates in a different environment and does not understand
how the shell has managed its job numbers.
Shell Command Language, ps, wait(), the System
Interfaces volume of IEEE Std 1003.1-2001, kill(), the Base
Definitions volume of IEEE Std 1003.1-2001, <signal.h>
signal_number sig Value 0 0 1 SIGHUP 2 SIGINT 3 SIGQUIT 6 SIGABRT 9 SIGKILL 14 SIGALRM 15 SIGTERM OPERANDS
STDIN
INPUT FILES
ENVIRONMENT VARIABLES
ASYNCHRONOUS EVENTS
STDOUT
"%s%c", <signal_name>, <separator>
"%s\n", <signal_name>
STDERR
OUTPUT FILES
EXTENDED DESCRIPTION
EXIT STATUS
CONSEQUENCES OF ERRORS
APPLICATION USAGE
nohup kill %1 &
system("kill %1");
EXAMPLES
kill -9 100 -165
kill -s kill 100 -165
kill -s KILL 100 -165
job
stat=$?
if [ $stat -eq 0 ]
then
echo job completed successfully.
elif [ $stat -gt 128 ]
then
echo job terminated by signal SIG$(kill -l $stat).
else
echo job terminated with error code $stat.
fi
kill -TERM -123
kill -- -123
RATIONALE
nohup kill %1 &
system("kill %1");
FUTURE DIRECTIONS
COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .
SEE ALSO