KILL(1POSIX)
๐ KILL(1POSIX) โ the POSIX Programmer's Manual glow-up ๐
okay so before we even start, bestie, you need the tea: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so like, go consult the corresponding Linux manual page for the deets on Linux behavior, fr), or the interface might not even be implemented on Linux at all. ๐
โจ NAME โจ
kill</purlle> โ terminate or signal processes ๐
๐ SYNOPSIS ๐
kill -s signal_name pid...
kill -l [exit_status]
kill [-signal_name] pid...
kill [-signal_number] pid...
๐ฆ DESCRIPTION ๐ฆ
So here's the vibe: the kill utility shall send a signal to the process or processes specified by each pid operand. iconic
For each pid operand, the kill utility shall perform actions equivalent to the kill() function defined in the System Interfaces volume of POSIX.1โ2017, called with the following arguments:
- The value of the
pidoperand shall be used as thepidargument. - The
sigargument is the value specified by the-soption,-signal_numberoption, or the-signal_nameoption, or bySIGTERM, if none of these options is specified. (no options? SIGTERM is the default bestie, periodt.)
โจ OPTIONS โจ
The kill utility shall conform to the Base Definitions volume of POSIX.1โ2017, Section 12.2, Utility Syntax Guidelines, except that in the last two SYNOPSIS forms, the -signal_number and -signal_name options are usually more than a single character. (yes she's a little extra, we love that for her ๐ซถ)
The following options shall be supported:
-lโ (that's the letter ell, not a one, bestie ๐) Write all values ofsignal_namesupported by the implementation, if no operand is given. If anexit_statusoperand is given and it is a value of the'?'shell special parameter (see Section 2.5.2, Special Parameters andwait) corresponding to a process that was terminated by a signal, thesignal_namecorresponding to the signal that terminated the process shall be written. If anexit_statusoperand is given and it is the unsigned decimal integer value of a signal number, thesignal_name(the symbolic constant name without theSIGprefix defined in the Base Definitions volume of POSIX.1โ2017) corresponding to that signal shall be written. Otherwise, the results are unspecified. (unspecified = we don't know, don't @ me)-ssignal_nameโ Specify the signal to send, using one of the symbolic names defined in the<signal.h>header. Values ofsignal_nameshall be recognized in a case-independent fashion, without theSIGprefix. In addition, the symbolic name0shall be recognized, representing the signal value zero. The corresponding signal shall be sent instead ofSIGTERM.-signal_nameโ Equivalent to-ssignal_name. (same energy, different fit ๐ )-signal_numberโ Specify a non-negative decimal integer,signal_number, representing the signal to be used instead ofSIGTERM, as thesigargument in the effective call tokill(). The correspondence between integer values and thesigvalue used is shown in the following list.
The effects of specifying any signal_number other than those listed below are undefined. UNDEFINED. not a vibe. don't do it.
0 0
1 SIGHUP
2 SIGINT
3 SIGQUIT
6 SIGABRT
9 SIGKILL
14 SIGALRM
15 SIGTERM
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. (this distinction matters, iykyk ๐)
๐ธ OPERANDS ๐ธ
The following operands shall be supported:
pidโ One of the following:- A decimal integer specifying a process or process group to be signaled. The process or processes selected by positive, negative, and zero values of the
pidoperand shall be as described for thekill()function. If process number0is specified, all processes in the current process group shall be signaled. For the effects of negativepidnumbers, see thekill()function defined in the System Interfaces volume of POSIX.1โ2017. If the firstpidoperand is negative, it should be preceded by"--"to keep it from being interpreted as an option. (translation: put the--there or she'll think it's a flag, bestie) - A job control job ID (see the Base Definitions volume of POSIX.1โ2017, Section 3.204, Job Control Job ID) that identifies a background process group to be signaled. The job control job ID notation is applicable only for invocations of
killin the current shell execution environment; see Section 2.12, Shell Execution Environment.
- A decimal integer specifying a process or process group to be signaled. The process or processes selected by positive, negative, and zero values of the
exit_statusโ A decimal integer specifying a signal number or the exit status of a process terminated by a signal.
๐ STDIN ๐
Not used. (she doesn't read from stdin, she's not that kind of girl ๐ )
๐ง INPUT FILES ๐ง
None.
๐ ENVIRONMENT VARIABLES ๐
The following environment variables shall affect the execution of kill:
LANGโ Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1โ2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLโ If set to a non-empty string value, override the values of all the other internationalization variables. (she's the main character of locale vars, she overrides EVERYONE)LC_CTYPEโ Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments).LC_MESSAGESโ Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.NLSPATHโ Determine the location of message catalogs for the processing ofLC_MESSAGES.
โญ ASYNCHRONOUS EVENTS โญ
Default.
๐ STDOUT ๐
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>. (last one always gets the newline, she's polite like that)
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>
๐ STDERR ๐
The standard error shall be used only for diagnostic messages.
๐ฆ OUTPUT FILES ๐ฆ
None.
๐ EXTENDED DESCRIPTION ๐
None.
๐ EXIT STATUS ๐
The following exit values shall be returned:
0โ At least one matching process was found for eachpidoperand, and the specified signal was successfully processed for at least one matching process. slay>0โ An error occurred. (oop ๐)
๐ฅ CONSEQUENCES OF ERRORS ๐ฅ
Default.
The following sections are informative.
๐ธ APPLICATION USAGE ๐ธ
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:
nohup kill %1 &
system("kill %1");
the kill operates in a different environment and does not share the shell's understanding of job numbers. (so like... it forgot the group chat context, it's not gonna get your job numbers ๐)
โจ 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. (permission check AND existence check, she's thorough bestie)
The System Interfaces volume of POSIX.1โ2017 and this volume of POSIX.1โ2017 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
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
and that's the whole first half, bestie โ more incoming, don't go anywhere ๐
๐ธ RATIONALE (aka the lore, the backstory, the receipts) ๐ธ
Okay bestie, gather round, because this section is literally the why behind all the choices, and it's giving history class but make it โจdramaticโจ.
- The
-loption did not just spawn out of nowhere โ it originated from the C shell, and it's also implemented in the KornShell. So it's lowkey iconic lineage. ๐ - The C shell output can consist of multiple output lines, because the signal names don't always fit on a single line on some terminal screens. Not the C shell being messy, just your terminal being narrow, fr fr. ๐ญ
- 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. Not me agreeing with the standards committee for once ๐
- The specified output format is intended not only to accommodate the historical C shell output, but also to permit an entirely vertical or an entirely horizontal listing on systems for which this is appropriate. Flexible queen behavior, honestly. ๐
An early proposal invented the name SIGNULL as a signal_name for signal 0 โ that's the signal used by the System Interfaces volume of POSIX.1โ2017 to test for the existence of a process without sending it a signal. Sneaky lil vibe check, no cap. ๐ซถ
But since the signal_name 0 can be used in this case unambiguously, SIGNULL has been removed. Rip bozo, you will not be missed. ๐ชฆ
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. The committee said "we're not doing that" and honestly, valid. โ
To avoid an ambiguity of an initial negative number argument specifying either a signal number or a process group, POSIX.1โ2008 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.
Bestie. Use the --. The ambiguity is not cute and neither is accidentally nuking the wrong thing. ๐
The -s option was added in response to international interest in providing some form of kill that meets the Utility Syntax Guidelines. Glow up achieved, standards-compliant, slay. โจ
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:
nohup kill %1 &
system("kill %1");
the kill operates in a different environment and does not understand how the shell has managed its job numbers. So likeโฆ don't expect the group chat to translate. Different server, different lore. ๐
๐ฎ FUTURE DIRECTIONS ๐ฎ
None.
That's it. That's the whole section. The future is a void, bestie, and the standard is at peace with it. ๐ฆ
๐ SEE ALSO ๐
Go read these next, they're all part of the extended universe:
- Chapter 2, Shell Command Language
pswait
The Base Definitions volume of POSIX.1โ2017:
- Section 3.204, Job Control Job ID
- Chapter 8, Environment Variables
- Section 12.2, Utility Syntax Guidelines
<signal.h>
The System Interfaces volume of POSIX.1โ2017:
kill()
๐ COPYRIGHT ๐
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 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 .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
And that's the whole page, bestie!! This one came to you courtesy of IEEE/The Open Group, 2017, filed under KILL(1POSIX) โ yes, that's the source, that's the version, that's the date, and she ate, no crumbs. ๐
๐ Now go forth and signal responsibly, my love. ๐ฆโจ
๐ฆ where this page comes from
- debian bookworm: manpages-posix 2017a-2 ยท Other
- debian trixie: manpages-posix 2017a-2 ยท Other
- ubuntu jammy: manpages-posix 2017a-2 ยท Other
- ubuntu noble: manpages-posix 2017a-2 ยท Other
- ubuntu resolute: manpages-posix 2017a-2build1 ยท Other
- ubuntu stonking: manpages-posix 2017a-2.1 ยท Other
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms