1KILL(1P)                   POSIX Programmer's Manual                  KILL(1P)
2
3
4

PROLOG

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
11

NAME

13       kill — terminate or signal processes
14

SYNOPSIS

16       kill −s signal_name pid...
17
18       kill −l [exit_status]
19
20       kill [signal_name] pid...
21
22       kill [signal_number] pid...
23

DESCRIPTION

25       The kill utility shall send a signal to the process or processes speci‐
26       fied by each pid operand.
27
28       For each pid operand, the kill utility shall perform actions equivalent
29       to the kill() function defined  in  the  System  Interfaces  volume  of
30       POSIX.1‐2008 called with the following arguments:
31
32        *  The value of the pid operand shall be used as the pid argument.
33
34        *  The  sig  argument  is  the value specified by the −s option, sig‐
35           nal_number option, or the signal_name option, or  by  SIGTERM,  if
36           none of these options is specified.
37

OPTIONS

39       The  kill  utility  shall  conform  to  the  Base Definitions volume of
40       POSIX.1‐2008, Section 12.2, Utility Syntax Guidelines, except  that  in
41       the  last  two  SYNOPSIS  forms,  the  signal_number  and signal_name
42       options are usually more than a single character.
43
44       The following options shall be supported:
45
46       −l        (The letter ell.) Write all values of  signal_name  supported
47                 by  the  implementation,  if  no  operand  is  given.  If  an
48                 exit_status operand is given and it is a  value  of  the  '?'
49                 shell  special  parameter (see Section 2.5.2, Special Parame‐
50                 ters and wait) corresponding to a process that was terminated
51                 by a signal, the signal_name corresponding to the signal that
52                 terminated the process shall be written.  If  an  exit_status
53                 operand is given and it is the unsigned decimal integer value
54                 of a signal number, the signal_name  (the  symbolic  constant
55                 name  without  the SIG prefix defined in the Base Definitions
56                 volume of POSIX.1‐2008) corresponding to that signal shall be
57                 written. Otherwise, the results are unspecified.
58
59       −s signal_name
60                 Specify  the  signal to send, using one of the symbolic names
61                 defined in the <signal.h> header. Values of signal_name shall
62                 be  recognized in a case-independent fashion, without the SIG
63                 prefix. In addition, the symbolic name 0 shall be recognized,
64                 representing  the signal value zero. The corresponding signal
65                 shall be sent instead of SIGTERM.
66
67       signal_name
68                 Equivalent to −s signal_name.
69
70       signal_number
71                 Specify a non-negative decimal integer, signal_number, repre‐
72                 senting  the signal to be used instead of SIGTERM, as the sig
73                 argument in the effective call to kill().  The correspondence
74                 between integer values and the sig value used is shown in the
75                 following list.
76
77                 The effects of specifying any signal_number other than  those
78                 listed below are undefined.
79
80                 0     0
81
82                 1     SIGHUP
83
84                 2     SIGINT
85
86                 3     SIGQUIT
87
88                 6     SIGABRT
89
90                 9     SIGKILL
91
92                 14    SIGALRM
93
94                 15    SIGTERM
95
96                 If  the  first  argument  is  a negative integer, it shall be
97                 interpreted as a signal_number option, not as a negative pid
98                 operand specifying a process group.
99

OPERANDS

101       The following operands shall be supported:
102
103       pid       One of the following:
104
105                  1. A  decimal  integer specifying a process or process group
106                     to be signaled.  The process  or  processes  selected  by
107                     positive,  negative,  and  zero values of the pid operand
108                     shall be as described for the kill() function. If process
109                     number  0  is  specified,  all  processes  in the current
110                     process group shall be signaled. For the effects of nega‐
111                     tive  pid numbers, see the kill() function defined in the
112                     System Interfaces volume of POSIX.1‐2008.  If  the  first
113                     pid operand is negative, it should be preceded by "−−" to
114                     keep it from being interpreted as an option.
115
116                  2. A job control job ID (see the Base Definitions volume  of
117                     POSIX.1‐2008,  Section  3.204,  Job  Control Job ID) that
118                     identifies a background process group to be signaled. The
119                     job  control job ID notation is applicable only for invo‐
120                     cations of kill in the current shell  execution  environ‐
121                     ment; see Section 2.12, Shell Execution Environment.
122
123       exit_status
124                 A decimal integer specifying a signal number or the exit sta‐
125                 tus of a process terminated by a signal.
126

STDIN

128       Not used.
129

INPUT FILES

131       None.
132

ENVIRONMENT VARIABLES

134       The following environment variables shall affect the execution of kill:
135
136       LANG      Provide a default value for  the  internationalization  vari‐
137                 ables  that are unset or null. (See the Base Definitions vol‐
138                 ume of POSIX.1‐2008, Section 8.2, Internationalization  Vari‐
139                 ables  for  the  precedence of internationalization variables
140                 used to determine the values of locale categories.)
141
142       LC_ALL    If set to a non-empty string value, override  the  values  of
143                 all the other internationalization variables.
144
145       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
146                 bytes of text data as characters (for example, single-byte as
147                 opposed to multi-byte characters in arguments).
148
149       LC_MESSAGES
150                 Determine the locale that should be used to affect the format
151                 and contents  of  diagnostic  messages  written  to  standard
152                 error.
153
154       NLSPATH   Determine the location of message catalogs for the processing
155                 of LC_MESSAGES.
156

ASYNCHRONOUS EVENTS

158       Default.
159

STDOUT

161       When the −l option is not specified, the standard output shall  not  be
162       used.
163
164       When the −l option is specified, the symbolic name of each signal shall
165       be written in the following format:
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           "%s\n", <signal_name>
178

STDERR

180       The standard error shall be used only for diagnostic messages.
181

OUTPUT FILES

183       None.
184

EXTENDED DESCRIPTION

186       None.
187

EXIT STATUS

189       The following exit values shall be returned:
190
191        0    At least one matching process was found for each pid operand, and
192             the  specified signal was successfully processed for at least one
193             matching process.
194
195       >0    An error occurred.
196

CONSEQUENCES OF ERRORS

198       Default.
199
200       The following sections are informative.
201

APPLICATION USAGE

203       Process numbers can be found by using ps.
204
205       The job control job ID notation is not required  to  work  as  expected
206       when  kill  is  operating  in its own utility execution environment. In
207       either of the following examples:
208
209           nohup kill %1 &
210           system("kill %1");
211
212       the kill operates in a different environment and  does  not  share  the
213       shell's understanding of job numbers.
214

EXAMPLES

216       Any of the commands:
217
218           kill −9 100 −165
219           kill −s kill 100 −165
220           kill −s KILL 100 −165
221
222       sends  the SIGKILL signal to the process whose process ID is 100 and to
223       all processes whose process group  ID  is  165,  assuming  the  sending
224       process  has permission to send that signal to the specified processes,
225       and that they exist.
226
227       The System  Interfaces  volume  of  POSIX.1‐2008  and  this  volume  of
228       POSIX.1‐2008  do  not  require  specific  signal  numbers  for any sig‐
229       nal_names.  Even the signal_number option provides symbolic  (although
230       numeric) names for signals. If a process is terminated by a signal, its
231       exit status indicates the signal that killed it, but the  exact  values
232       are not specified. The kill −l option, however, can be used to map dec‐
233       imal signal numbers and exit status values into the name of  a  signal.
234       The following example reports the status of a terminated job:
235
236           job
237           stat=$?
238           if [ $stat −eq 0 ]
239           then
240               echo job completed successfully.
241           elif [ $stat −gt 128 ]
242           then
243               echo job terminated by signal SIG$(kill −l $stat).
244           else
245               echo job terminated with error code $stat.
246           fi
247
248       To send the default signal to a process group (say 123), an application
249       should use a command similar to one of the following:
250
251           kill −TERM −123
252           kill −− −123
253

RATIONALE

255       The −l option originated from the C shell, and is also  implemented  in
256       the  KornShell. The C shell output can consist of multiple output lines
257       because the signal names do not always fit on a  single  line  on  some
258       terminal  screens.  The  KornShell output also included the implementa‐
259       tion-defined signal numbers and was considered by the standard develop‐
260       ers  to  be too difficult for scripts to parse conveniently. The speci‐
261       fied output format is intended not only to accommodate the historical C
262       shell output, but also to permit an entirely vertical or entirely hori‐
263       zontal listing on systems for which this is appropriate.
264
265       An early proposal invented the name SIGNULL as a signal_name for signal
266       0 (used by the System Interfaces volume of POSIX.1‐2008 to test for the
267       existence of a process without sending it a  signal).  Since  the  sig‐
268       nal_name  0  can  be  used in this case unambiguously, SIGNULL has been
269       removed.
270
271       An early proposal also required symbolic signal_names to be  recognized
272       with  or  without  the SIG prefix. Historical versions of kill have not
273       written the SIG prefix for the −l option and have  not  recognized  the
274       SIG prefix on signal_names.  Since neither applications portability nor
275       ease-of-use would be improved by requiring this  extension,  it  is  no
276       longer required.
277
278       To avoid an ambiguity of an initial negative number argument specifying
279       either a signal number or a process group, POSIX.1‐2008  mandates  that
280       it  is always considered the former by implementations that support the
281       XSI option. It also requires that conforming  applications  always  use
282       the  "−−"  options terminator argument when specifying a process group,
283       unless an option is also specified.
284
285       The −s option was added in response to international interest  in  pro‐
286       viding some form of kill that meets the Utility Syntax Guidelines.
287
288       The  job  control  job  ID notation is not required to work as expected
289       when kill is operating in its own  utility  execution  environment.  In
290       either of the following examples:
291
292           nohup kill %1 &
293           system("kill %1");
294
295       the  kill  operates  in a different environment and does not understand
296       how the shell has managed its job numbers.
297

FUTURE DIRECTIONS

299       None.
300

SEE ALSO

302       Chapter 2, Shell Command Language, ps, wait
303
304       The Base Definitions volume of POSIX.1‐2008, Section 3.204, Job Control
305       Job  ID, Chapter 8, Environment Variables, Section 12.2, Utility Syntax
306       Guidelines, <signal.h>
307
308       The System Interfaces volume of POSIX.1‐2008, kill()
309
311       Portions of this text are reprinted and reproduced in  electronic  form
312       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
313       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
314       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
315       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
316       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
317       event of any discrepancy between this version and the original IEEE and
318       The  Open Group Standard, the original IEEE and The Open Group Standard
319       is the referee document. The original Standard can be  obtained  online
320       at http://www.unix.org/online.html .
321
322       Any  typographical  or  formatting  errors that appear in this page are
323       most likely to have been introduced during the conversion of the source
324       files  to  man page format. To report such errors, see https://www.ker
325       nel.org/doc/man-pages/reporting_bugs.html .
326
327
328
329IEEE/The Open Group                  2013                             KILL(1P)
Impressum