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