NAME
kill — terminate
or signal processes
SYNOPSIS
kill |
-s signal_name
pid ... |
kill |
-l [exit_status] |
Obsolescent |
Versions: |
kill |
[-signal_name] pid
... |
kill |
[-signal_number] pid
... |
DESCRIPTION
The kill utility shall send a signal to
the process(es) specified by each pid operand. For each pid operand, the
kill utility shall perform actions equivalent to the
POSIX. 1 {8} kill function 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
utility argument syntax guidelines described in 2.10.2, except that in the
obsolescent form, the −signal_number and −signal_name options
are usually more than a single character. The following options shall be
supported by the implementation:
-l-
(The letter ell.) Write all values of signal_name supported by the implementation, if no operand is given. If an exit_status operand is given and it is a value of the ? shell special parameter (see 3.5.2 and wait in wait(1) ) corresponding to a process that was terminated by a signal, the signal_name corresponding to the signal that terminated the process shall be written. If an exit_status operand is given and it is the unsigned decimal integer value of a signal number, the signal_name (the POSIX. 1 {8}-defined symbolic constant name without the SIG prefix) corresponding to that signal shall be written. Otherwise, the results are unspecified.
-s-
signal_name Specify the signal to send, using one of the symbolic names defined for Required Signals or Job Control Signals in POSIX. 1 {8} 3.3.1.1. Values of signal_name shall be recognized in a caseindependent 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. −signal_name (Obsolescent.) Equivalent to −s signal_name. −signal_number (Obsolescent.) Specify a nonnegative 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.signal_number sig
Value 0 0 1 SIGHUP 2 SIGINT 3 SIGQUIT 6 SIGABRT 9 SIGKILL 14 SIGALRM 15 SIGTERM
The effects of specifying any signal_number other than those listed in the table are undefined. In the obsolescent versions, 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.
OPERANDS
The following operands shall be supported by the implementation:
- pid
-
A decimal integer specifying a process or process group to be signaled. The process(es) selected by positive, negative, and zero values of the pid operand shall be as described for POSIX. 1 {8}
killfunction. If the first pid operand is negative, it should be preceded by -- to keep it from being interpreted as an option. - exit_status
-
A decimal integer specifying a signal number or the exit status of a process terminated by a signal.
STANDARD INPUT
None.
INPUT FILES
None.
ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of
kill:
LANG-
This variable shall determine the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_ ) do not specify a locale. See 2.6.
LC_ALL-
This variable shall determine the locale to be used to override any values for locale categories specified by the settings of LANG or any environment variables beginning with LC_.
LC_CTYPE-
This variable shall determine the locale for the interpretation of sequences of bytes of text data as characters (e.g., single- versus multibyte characters in arguments).
LC_MESSAGES-
This variable shall determine the language in which messages should be written.
ASYNCHRONOUS EVENTS
Default.
STANDARD OUTPUT
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: "%s%c", <signal_name>, <separator> 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: "%s\n", <signal_name>
STANDARD ERROR
Used only for diagnostic messages.
OUTPUT FILES
None.
EXTENDED DESCRIPTION
None.
EXIT STATUS
The kill utility shall exit with one of
the following values:
CONSEQUENCES OF ERRORS
Default.
RATIONALE
EXAMPLES
Any of the commands kill −9 100
-165 kill −s kill 100
-165 kill −s
KILL 100
-165 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. POSIX. 1 {8} and
POSIX. 2 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: 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
HISTORY OF DECISIONS MADE
The signal name extension was based on a desire to avoid limiting
the kill utility to implementation-dependent values.
The −l option originated from the C-shell, and is also implemented in
the Korn- Shell. 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-specific
signal numbers, and was felt by the working group 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 earlier draft invented the name SIGNULL
as a signal_name for signal 0 (used by POSIX. 1 {8} 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 earlier draft 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 application
portability nor ease of use would be improved by requiring this extension,
it is no longer required. POSIX. 2 contains no utility
that browses for process IDs. Values for pid are available via the ! and $
parameters of the shell command language (see 3.5.2). The use of numeric
signal values was the subject of a long debate in the Working Group. During
balloting, it was determined that their use should be declared obsolescent,
but retained to provide backward compatibility to existing applications.
Existing implementations of kill permit negative pid
operands representing process groups, but this was often unclearly
documented. The assumption that an
initial negative number argument specifies a signal
number (rather than a process group) is the existing behavior, and was
retained. Therefore, to send the default signal to a process group (say
123), an application should use a command similar to one of the following:
kill -
TERM -123
kill -- -123 The −s option was added in
response to international interest in providing some form of
kill that meets the Utility Syntax Guidelines. Some
implementations provide kill only as a shell
built-in utility and use that status to support the extension of killing
background asynchronous lists (those started with &), by the use of job
identifiers. For example, kill %1 would
kill the first asynchronous list in the background.
This standard does not require (but permits) such an extension, because
other related job-control features are not provided by the shell, and
because these facilities are not ordinarily usable in portable shell
applications. This notation is expected to be introduced by the
UPE.