1KILL(1P) POSIX Programmer's Manual KILL(1P)
2
3
4
6 This manual page is part of the POSIX Programmer's Manual. The Linux
7 implementation of this interface may differ (consult the corresponding
8 Linux manual page for details of Linux behavior), or the interface may
9 not be implemented on Linux.
10
12 kill — terminate or signal processes
13
15 kill -s signal_name pid...
16
17 kill -l [exit_status]
18
19 kill [-signal_name] pid...
20
21 kill [-signal_number] pid...
22
24 The kill utility shall send a signal to the process or processes speci‐
25 fied by each pid operand.
26
27 For each pid operand, the kill utility shall perform actions equivalent
28 to the kill() function defined in the System Interfaces volume of
29 POSIX.1‐2017 called with the following arguments:
30
31 * The value of the pid operand shall be used as the pid argument.
32
33 * The sig argument is the value specified by the -s option, -sig‐
34 nal_number option, or the -signal_name option, or by SIGTERM, if
35 none of these options is specified.
36
38 The kill utility shall conform to the Base Definitions volume of
39 POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines, except that in
40 the last two SYNOPSIS forms, the -signal_number and -signal_name
41 options are usually more than a single character.
42
43 The following options shall be supported:
44
45 -l (The letter ell.) Write all values of signal_name supported
46 by the implementation, if no operand is given. If an
47 exit_status operand is given and it is a value of the '?'
48 shell special parameter (see Section 2.5.2, Special Parame‐
49 ters and wait) corresponding to a process that was terminated
50 by a signal, the signal_name corresponding to the signal that
51 terminated the process shall be written. If an exit_status
52 operand is given and it is the unsigned decimal integer value
53 of a signal number, the signal_name (the symbolic constant
54 name without the SIG prefix defined in the Base Definitions
55 volume of POSIX.1‐2017) corresponding to that signal shall be
56 written. Otherwise, the results are unspecified.
57
58 -s signal_name
59 Specify the signal to send, using one of the symbolic names
60 defined in the <signal.h> header. Values of signal_name shall
61 be recognized in a case-independent fashion, without the SIG
62 prefix. In addition, the symbolic name 0 shall be recognized,
63 representing the signal value zero. The corresponding signal
64 shall be sent instead of SIGTERM.
65
66 -signal_name
67 Equivalent to -s signal_name.
68
69 -signal_number
70 Specify a non-negative decimal integer, signal_number, repre‐
71 senting the signal to be used instead of SIGTERM, as the sig
72 argument in the effective call to kill(). The correspondence
73 between integer values and the sig value used is shown in the
74 following list.
75
76 The effects of specifying any signal_number other than those
77 listed below are undefined.
78
79 0 0
80
81 1 SIGHUP
82
83 2 SIGINT
84
85 3 SIGQUIT
86
87 6 SIGABRT
88
89 9 SIGKILL
90
91 14 SIGALRM
92
93 15 SIGTERM
94
95 If the first argument is a negative integer, it shall be
96 interpreted as a -signal_number option, not as a negative pid
97 operand specifying a process group.
98
100 The following operands shall be supported:
101
102 pid One of the following:
103
104 1. A decimal integer specifying a process or process group
105 to be signaled. The process or processes selected by
106 positive, negative, and zero values of the pid operand
107 shall be as described for the kill() function. If process
108 number 0 is specified, all processes in the current
109 process group shall be signaled. For the effects of nega‐
110 tive pid numbers, see the kill() function defined in the
111 System Interfaces volume of POSIX.1‐2017. If the first
112 pid operand is negative, it should be preceded by "--" to
113 keep it from being interpreted as an option.
114
115 2. A job control job ID (see the Base Definitions volume of
116 POSIX.1‐2017, Section 3.204, Job Control Job ID) that
117 identifies a background process group to be signaled. The
118 job control job ID notation is applicable only for invo‐
119 cations of kill in the current shell execution environ‐
120 ment; see Section 2.12, Shell Execution Environment.
121
122 exit_status
123 A decimal integer specifying a signal number or the exit sta‐
124 tus of a process terminated by a signal.
125
127 Not used.
128
130 None.
131
133 The following environment variables shall affect the execution of kill:
134
135 LANG Provide a default value for the internationalization vari‐
136 ables that are unset or null. (See the Base Definitions vol‐
137 ume of POSIX.1‐2017, Section 8.2, Internationalization Vari‐
138 ables for the precedence of internationalization variables
139 used to determine the values of locale categories.)
140
141 LC_ALL If set to a non-empty string value, override the values of
142 all the other internationalization variables.
143
144 LC_CTYPE Determine the locale for the interpretation of sequences of
145 bytes of text data as characters (for example, single-byte as
146 opposed to multi-byte characters in arguments).
147
148 LC_MESSAGES
149 Determine the locale that should be used to affect the format
150 and contents of diagnostic messages written to standard
151 error.
152
153 NLSPATH Determine the location of message catalogs for the processing
154 of LC_MESSAGES.
155
157 Default.
158
160 When the -l option is not specified, the standard output shall not be
161 used.
162
163 When the -l option is specified, the symbolic name of each signal shall
164 be written in the following format:
165
166
167 "%s%c", <signal_name>, <separator>
168
169 where the <signal_name> is in uppercase, without the SIG prefix, and
170 the <separator> shall be either a <newline> or a <space>. For the last
171 signal written, <separator> shall be a <newline>.
172
173 When both the -l option and exit_status operand are specified, the sym‐
174 bolic name of the corresponding signal shall be written in the follow‐
175 ing format:
176
177
178 "%s\n", <signal_name>
179
181 The standard error shall be used only for diagnostic messages.
182
184 None.
185
187 None.
188
190 The following exit values shall be returned:
191
192 0 At least one matching process was found for each pid operand, and
193 the specified signal was successfully processed for at least one
194 matching process.
195
196 >0 An error occurred.
197
199 Default.
200
201 The following sections are informative.
202
204 Process numbers can be found by using ps.
205
206 The job control job ID notation is not required to work as expected
207 when kill is operating in its own utility execution environment. In
208 either of the following examples:
209
210
211 nohup kill %1 &
212 system("kill %1");
213
214 the kill operates in a different environment and does not share the
215 shell's understanding of job numbers.
216
218 Any of the commands:
219
220
221 kill -9 100 -165
222 kill -s kill 100 -165
223 kill -s KILL 100 -165
224
225 sends the SIGKILL signal to the process whose process ID is 100 and to
226 all processes whose process group ID is 165, assuming the sending
227 process has permission to send that signal to the specified processes,
228 and that they exist.
229
230 The System Interfaces volume of POSIX.1‐2017 and this volume of
231 POSIX.1‐2017 do not require specific signal numbers for any sig‐
232 nal_names. Even the -signal_number option provides symbolic (although
233 numeric) names for signals. If a process is terminated by a signal, its
234 exit status indicates the signal that killed it, but the exact values
235 are not specified. The kill -l option, however, can be used to map dec‐
236 imal signal numbers and exit status values into the name of a signal.
237 The following example reports the status of a terminated job:
238
239
240 job
241 stat=$?
242 if [ $stat -eq 0 ]
243 then
244 echo job completed successfully.
245 elif [ $stat -gt 128 ]
246 then
247 echo job terminated by signal SIG$(kill -l $stat).
248 else
249 echo job terminated with error code $stat.
250 fi
251
252 To send the default signal to a process group (say 123), an application
253 should use a command similar to one of the following:
254
255
256 kill -TERM -123
257 kill -- -123
258
260 The -l option originated from the C shell, and is also implemented in
261 the KornShell. The C shell output can consist of multiple output lines
262 because the signal names do not always fit on a single line on some
263 terminal screens. The KornShell output also included the implementa‐
264 tion-defined signal numbers and was considered by the standard develop‐
265 ers to be too difficult for scripts to parse conveniently. The speci‐
266 fied output format is intended not only to accommodate the historical C
267 shell output, but also to permit an entirely vertical or entirely hori‐
268 zontal listing on systems for which this is appropriate.
269
270 An early proposal invented the name SIGNULL as a signal_name for signal
271 0 (used by the System Interfaces volume of POSIX.1‐2017 to test for the
272 existence of a process without sending it a signal). Since the sig‐
273 nal_name 0 can be used in this case unambiguously, SIGNULL has been
274 removed.
275
276 An early proposal also required symbolic signal_names to be recognized
277 with or without the SIG prefix. Historical versions of kill have not
278 written the SIG prefix for the -l option and have not recognized the
279 SIG prefix on signal_names. Since neither applications portability nor
280 ease-of-use would be improved by requiring this extension, it is no
281 longer required.
282
283 To avoid an ambiguity of an initial negative number argument specifying
284 either a signal number or a process group, POSIX.1‐2008 mandates that
285 it is always considered the former by implementations that support the
286 XSI option. It also requires that conforming applications always use
287 the "--" options terminator argument when specifying a process group,
288 unless an option is also specified.
289
290 The -s option was added in response to international interest in pro‐
291 viding some form of kill that meets the Utility Syntax Guidelines.
292
293 The job control job ID notation is not required to work as expected
294 when kill is operating in its own utility execution environment. In
295 either of the following examples:
296
297
298 nohup kill %1 &
299 system("kill %1");
300
301 the kill operates in a different environment and does not understand
302 how the shell has managed its job numbers.
303
305 None.
306
308 Chapter 2, Shell Command Language, ps, wait
309
310 The Base Definitions volume of POSIX.1‐2017, Section 3.204, Job Control
311 Job ID, Chapter 8, Environment Variables, Section 12.2, Utility Syntax
312 Guidelines, <signal.h>
313
314 The System Interfaces volume of POSIX.1‐2017, kill()
315
317 Portions of this text are reprinted and reproduced in electronic form
318 from IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
319 table Operating System Interface (POSIX), The Open Group Base Specifi‐
320 cations Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of
321 Electrical and Electronics Engineers, Inc and The Open Group. In the
322 event of any discrepancy between this version and the original IEEE and
323 The Open Group Standard, the original IEEE and The Open Group Standard
324 is the referee document. The original Standard can be obtained online
325 at http://www.opengroup.org/unix/online.html .
326
327 Any typographical or formatting errors that appear in this page are
328 most likely to have been introduced during the conversion of the source
329 files to man page format. To report such errors, see https://www.ker‐
330 nel.org/doc/man-pages/reporting_bugs.html .
331
332
333
334IEEE/The Open Group 2017 KILL(1P)