summaryrefslogtreecommitdiff
path: root/usr/src/man/man1/kill.1
blob: f772da742130f2443d5386475e2c460f754753aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
.\" between these versions 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.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
.\"
.TH KILL 1 "Aug 11, 2009"
.SH NAME
kill \- terminate or signal processes
.SH SYNOPSIS
.LP
.nf
\fB/usr/bin/kill\fR \fB-s\fR \fIsignal_name\fR \fIpid\fR...
.fi

.LP
.nf
\fB/usr/bin/kill\fR \fB-l\fR [\fIexit_status\fR]
.fi

.LP
.nf
\fB/usr/bin/kill\fR [\fB-\fIsignal_name\fR\fR] \fIpid\fR...
.fi

.LP
.nf
\fB/usr/bin/kill\fR [\fB-\fIsignal_number\fR\fR] \fIpid\fR...
.fi

.SH DESCRIPTION
.sp
.LP
The \fBkill\fR utility sends a signal to the process or processes specified by
each \fIpid\fR operand.
.sp
.LP
For each \fIpid\fR operand, the \fBkill\fR utility performs actions equivalent
to the \fBkill\fR(2) function called with the following arguments:
.RS +4
.TP
1.
The value of the \fIpid\fR operand is used as the \fIpid\fR argument.
.RE
.RS +4
.TP
2.
The \fIsig\fR argument is the value specified by the \fB-s\fR option, the
\fB-\fR\fIsignal_name\fR option, or the \fB-\fR\fIsignal_number\fR option, or,
if none of these options is specified, by \fBSIGTERM\fR.
.RE
.sp
.LP
The signaled process must belong to the current user unless the user is the
super-user.
.sp
.LP
See NOTES for descriptions of the shell built-in versions of \fBkill\fR.
.SH OPTIONS
.sp
.LP
The following options are supported:
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.RS 18n
(The letter ell.) Writes all values of \fIsignal_name\fR supported by the
implementation, if no operand is specified. If an \fIexit_status\fR operand is
specified and it is a value of the \fB?\fR shell special parameter and
\fBwait\fR corresponding to a process that was terminated by a signal, the
\fIsignal_name\fR corresponding to the signal that terminated the process is
written. If an \fIexit_status\fR operand is specified and it is the unsigned
decimal integer value of a signal number, the \fIsignal_name\fR corresponding
to that signal is written. Otherwise, the results are unspecified.
.RE

.sp
.ne 2
.na
\fB\fB-s\fR \fIsignal_name\fR\fR
.ad
.RS 18n
Specifies the signal to send, using one of the symbolic names defined in the
\fB<signal.h>\fR description. Values of \fIsignal_name\fR is recognized in a
case-independent fashion, without the \fBSIG\fR prefix. In addition, the
symbolic name \fB0\fR is recognized, representing the signal value zero. The
corresponding signal is sent instead of \fBSIGTERM\fR.
.RE

.sp
.ne 2
.na
\fB\fB-\fR\fIsignal_name\fR\fR
.ad
.RS 18n
Equivalent to \fB-s\fR \fIsignal_name\fR.
.RE

.sp
.ne 2
.na
\fB\fB-\fR\fIsignal_number\fR\fR
.ad
.RS 18n
Specifies a non-negative decimal integer, \fIsignal_number\fR, representing the
signal to be used instead of \fBSIGTERM\fR, as the \fIsig\fR argument in the
effective call to \fBkill\fR(2).
.RE

.SH OPERANDS
.sp
.LP
The following operands are supported:
.sp
.ne 2
.na
\fB\fIpid\fR\fR
.ad
.RS 15n
One of the following:
.RS +4
.TP
1.
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
\fIpid\fR operand is as described for the kill function. If process number 0 is
specified, all processes in the process group are signaled. If the first
\fIpid\fR operand is negative, it should be preceded by \fB\(mi\(mi\fR to keep
it from being interpreted as an option.
.RE
.RS +4
.TP
2.
A job control job \fBID\fR that identifies a background process group to be
signaled. The job control job \fBID\fR notation is applicable only for
invocations of \fBkill\fR in the current shell execution environment.
.RE
The job control job \fBID\fR type of \fIpid\fR is available only on systems
supporting the job control option.
.RE

.sp
.ne 2
.na
\fB\fIexit_status\fR\fR
.ad
.RS 15n
A decimal integer specifying a signal number or the exit status of a process
terminated by a signal.
.RE

.SH USAGE
.sp
.LP
Process numbers can be found by using \fBps\fR(1).
.sp
.LP
The job control job \fBID\fR notation is not required to work as expected when
\fBkill\fR is operating in its own utility execution environment. In either of
the following examples:
.sp
.in +2
.nf
example% \fBnohup kill %1 &\fR
example% \fBsystem( "kill %1");\fR
.fi
.in -2
.sp

.sp
.LP
\fBkill\fR operates in a different environment and does not share the shell's
understanding of job numbers.
.SH OUTPUT
.sp
.LP
When the \fB-l\fR option is not specified, the standard output is not be used.
.sp
.LP
When the \fB-l\fR option is specified, the symbolic name of each signal is
written in the following format:
.sp
.in +2
.nf
"%s%c", <\fIsignal_name\fR>, <\fIseparator\fR>
.fi
.in -2

.sp
.LP
where the \fB<\fR\fIsignal_name\fR\fB>\fR is in upper-case, without the
\fBSIG\fR prefix, and the \fB<\fR\fIseparator\fR\fB>\fR is either a newline
character or a space character. For the last signal written,
\fB<\fR\fIseparator\fR\fB>\fR is a newline character.
.sp
.LP
When both the \fB-l\fR option and \fIexit_status\fR operand are specified, the
symbolic name of the corresponding signal is written in the following format:
.sp
.in +2
.nf
"%s\en", <\fIsignal_name\fR>
.fi
.in -2

.SH EXAMPLES
.LP
\fBExample 1 \fRSending the kill signal
.sp
.LP
Any of the commands:

.sp
.in +2
.nf
example% \fBkill -9 100 -165\fR
example% \fBkill -s kill 100 -165\fR
example% \fBkill -s KILL 100 -165\fR
.fi
.in -2
.sp

.sp
.LP
sends the \fBSIGKILL\fR signal to the process whose process \fBID\fR is
\fB100\fR and to all processes whose process group \fBID\fR is \fB165\fR,
assuming the sending process has permission to send that signal to the
specified processes, and that they exist.

.LP
\fBExample 2 \fRAvoiding ambiguity with an initial negative number
.sp
.LP
To avoid an ambiguity of an initial negative number argument specifying either
a signal number or a process group, the former is always be the case.
Therefore, to send the default signal to a process group (for example,
\fB123\fR), an application should use a command similar to one of the
following:

.sp
.in +2
.nf
example% \fBkill -TERM -123\fR
example% \fBkill -- -123\fR
.fi
.in -2
.sp

.SH ENVIRONMENT VARIABLES
.sp
.LP
See \fBenviron\fR(5) for descriptions of the following environment variables
that affect the execution of \fBkill\fR: \fBLANG\fR, \fBLC_ALL\fR,
\fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
At least one matching process was found for each \fIpid\fR operand, and the
specified signal was successfully processed for at least one matching process.
.RE

.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.SS "/usr/bin/kill, csh, ksh, sh"
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
CSI	Enabled
_
Interface Stability	Committed
_
Standard	See \fBstandards\fR(5).
.TE

.SS "ksh93"
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
CSI	Enabled
_
Interface Stability	Uncommitted
.TE

.SH SEE ALSO
.sp
.LP
\fBcsh\fR(1), \fBgetconf\fR(1), \fBjobs\fR(1), \fBksh\fR(1), \fBksh93\fR(1),
\fBps\fR(1), \fBsh\fR(1), \fBshell_builtins\fR(1), \fBwait\fR(1),
\fBkill\fR(2), \fBsignal\fR(3C), \fBsignal.h\fR(3HEAD), \fBattributes\fR(5),
\fBenviron\fR(5), \fBstandards\fR(5)
.SH NOTES
.SS "/usr/bin/kill"
.sp
.LP
The number of realtime signals supported is defined by the \fBgetconf\fR(1)
value \fB_POSIX_RTSIG_MAX\fR.
.SS "sh"
.sp
.LP
The Bourne shell, \fBsh\fR, has a built-in version of \fBkill\fR to provide the
functionality of the \fBkill\fR command for processes identified with a
\fIjobid\fR. The \fBsh\fR syntax is:
.sp
.in +2
.nf
kill [ -sig ] [ pid ] [ %job ]...
kill -l
.fi
.in -2
.sp

.SS "csh"
.sp
.LP
The C-shell, \fBcsh\fR, also has a built-in \fBkill\fR command, whose syntax
is:
.sp
.in +2
.nf
kill [-sig][pid][%job]...
kill -l
.fi
.in -2
.sp

.sp
.LP
The \fBcsh\fR \fBkill\fR built-in sends the \fBTERM\fR (terminate) signal, by
default, or the signal specified, to the specified process \fBID\fR, the
\fIjob\fR indicated, or the current \fIjob\fR. Signals are either specified by
number or by name. There is no default. Typing \fBkill\fR does not send a
signal to the current job. If the signal being sent is \fBTERM\fR (terminate)
or \fBHUP\fR (hangup), then the job or process is sent a \fBCONT\fR (continue)
signal as well.
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.RS 6n
Lists the signal names that can be sent.
.RE

.SS "ksh"
.sp
.LP
The syntax of the \fBksh\fR \fBkill\fR is:
.sp
.in +2
.nf
kill [-sig][pid][%job]...
kill -l
.fi
.in -2
.sp

.sp
.LP
The \fBksh\fR \fBkill\fR sends either the \fBTERM\fR (terminate) signal or the
specified signal to the specified jobs or processes. Signals are either
specified by number or by names (as specified in \fBsignal.h\fR(3HEAD) stripped
of the \fBSIG\fR prefix). If the signal being sent is \fBTERM\fR (terminate) or
\fBHUP\fR (hangup), then the job or process is sent a \fBCONT\fR (continue)
signal if it is stopped. The argument \fIjob\fR can be the process id of a
process that is not a member of one of the active jobs. In the second form,
\fBkill\fR \fB-l\fR, the signal numbers and names are listed.
.SS "ksh93"
.sp
.LP
The syntax of the \fBksh93\fR \fBkill\fR is:
.sp
.in +2
.nf
kill [-n signum] [-s signame] job ...
kill [-n signum] [-s signame] -l [arg ...]
.fi
.in -2
.sp

.sp
.LP
With the first form in which \fB-l\fR is not specified, \fBkill\fR sends a
signal to one or more processes specified by \fIjob\fR. This normally
terminates the processes unless the signal is being caught or ignored.
.sp
.LP
Specify \fIjob\fR as one of the following:
.sp
.ne 2
.na
\fB\fInumber\fR\fR
.ad
.RS 12n
The process id of \fIjob\fR.
.RE

.sp
.ne 2
.na
\fB\fB-\fR\fInumber\fR\fR
.ad
.RS 12n
The process group id of \fIjob\fR.
.RE

.sp
.ne 2
.na
\fB\fB%\fR\fInumber\fR\fR
.ad
.RS 12n
The job number.
.RE

.sp
.ne 2
.na
\fB\fB%\fR\fIstring\fR\fR
.ad
.RS 12n
The job whose name begins with \fIstring\fR.
.RE

.sp
.ne 2
.na
\fB\fB%?\fR\fIstring\fR\fR
.ad
.RS 12n
The job whose name contains \fIstring\fR.
.RE

.sp
.ne 2
.na
\fB\fB%+\fR\fR
.ad
.br
.na
\fB\fB%%\fR\fR
.ad
.RS 12n
The current job.
.RE

.sp
.ne 2
.na
\fB\fB%-\fR\fR
.ad
.RS 12n
The previous job.
.RE

.sp
.LP
If the signal is not specified with either the \fB-n\fR or the \fB-s\fR option,
the \fBSIGTERM\fR signal is used.
.sp
.LP
If \fB-l\fR is specified, and no \fIarg\fR is specified, then \fBkill\fR writes
the list of signals to standard output. Otherwise, \fIarg\fR can be either a
signal name, or a number representing either a signal number or exit status for
a process that was terminated due to a signal. If a name is specified  the
corresponding signal number is written to standard output. If a number is
specified the corresponding signal name is written to standard output.
.sp
.ne 2
.na
\fB\fB-l\fR\fR
.ad
.RS 14n
List signal names or signal numbers rather than sending signals as described
above. The \fB-n\fR and \fB-s\fR options cannot be specified.
.RE

.sp
.ne 2
.na
\fB\fB-n\fR \fIsignum\fR\fR
.ad
.RS 14n
Specify a signal number to send. Signal numbers are not portable across
platforms, except for the following:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
No signal.
.RE

.sp
.ne 2
.na
\fB\fB1\fR\fR
.ad
.RS 6n
\fBHUP\fR
.RE

.sp
.ne 2
.na
\fB\fB2\fR\fR
.ad
.RS 6n
\fBINT\fR
.RE

.sp
.ne 2
.na
\fB\fB3\fR\fR
.ad
.RS 6n
\fBQUIT\fR
.RE

.sp
.ne 2
.na
\fB\fB6\fR\fR
.ad
.RS 6n
\fBABRT\fR
.RE

.sp
.ne 2
.na
\fB\fB9\fR\fR
.ad
.RS 6n
\fBKILL\fR
.RE

.sp
.ne 2
.na
\fB\fB14\fR\fR
.ad
.RS 6n
\fBALRM\fR
.RE

.sp
.ne 2
.na
\fB\fB15\fR\fR
.ad
.RS 6n
\fBTERM\fR
.RE

.RE

.sp
.ne 2
.na
\fB\fB-s\fR \fIsigname\fR\fR
.ad
.RS 14n
Specify a signal name to send. The signal names are derived from their names in
\fB<signal.h>\fR without the \fBSIG\fR prefix and are case insensitive.
\fBkill\fR \fB-l\fR generates the list of signals on the current platform.
.RE

.sp
.LP
\fBkill\fR in \fBksh93\fR exits with one of the following values:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
At least one matching process was found for each job operand, and the specified
signal was successfully sent to at least one matching process.
.RE

.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE