]> git.ipfire.org Git - thirdparty/util-linux.git/blame - misc-utils/kill.1
Manual pages: order NOTES / HISTORY / BUGS / EXAMPLE consistently
[thirdparty/util-linux.git] / misc-utils / kill.1
CommitLineData
6dbe3af9
KZ
1.\" Copyright 1994 Salvatore Valente (svalente@mit.edu)
2.\" Copyright 1992 Rickard E. Faith (faith@cs.unc.edu)
3.\" May be distributed under the GNU General Public License
6e6b9a1d 4.TH KILL 1 "November 2019" "util-linux" "User Commands"
6dbe3af9
KZ
5.SH NAME
6kill \- terminate a process
7.SH SYNOPSIS
b0315e1f 8.B kill
83098262 9.RB [ \- \fIsignal\fR| \-s
1c4c6024 10.IR signal | \fB\-p\fP ]
a1504d8b 11.RB [ \-q
83098262 12.IR value ]
821ac2c7 13.RB [ \-a ]
6e6b9a1d 14\fR[\fB\-\-timeout \fImilliseconds signal\fR]
b0315e1f 15.RB [ \-\- ]
83098262 16.IR pid | name ...
6dbe3af9 17.br
83098262
BS
18.B kill \-l
19.RI [ number ]
20.RB "| " \-L
6dbe3af9 21.SH DESCRIPTION
c07ebfa1 22The command
6dbe3af9 23.B kill
83098262 24sends the specified \fIsignal\fR to the specified processes or process groups.
3d463c67
MK
25.PP
26If no signal is specified, the TERM signal is sent.
27The default action for this signal is to terminate the process.
28This signal should be used in preference to the
29KILL signal (number 9), since a process may install a handler for the
30TERM signal in order to perform clean-up steps before terminating in
31an orderly fashion.
32If a process does not terminate after a TERM signal has been sent,
33then the KILL signal may be used; be aware that the latter signal
34cannot be caught, and so does not give the target process the opportunity
8419465d 35to perform any clean-up before terminating.
c07ebfa1 36.PP
85c928ca 37Most modern shells have a builtin kill command, with a usage rather similar to
83098262
BS
38that of the command described here. The
39.BR \-\-all ,
40.BR \-\-pid ", and"
0bb7e904 41.B \-\-queue
83098262 42options, and the possibility to specify processes by command name, are local extensions.
bd0fb63d 43.PP
83098262
BS
44If \fIsignal\fR is 0, then no actual signal is sent, but error checking is still performed.
45
46.SH ARGUMENTS
2085ba6c 47The list of processes to be signaled can be a mixture of names and PIDs.
6dbe3af9 48.TP
83098262
BS
49.I pid
50Each
6dbe3af9 51.I pid
10ab72e7 52can be one of four things:
c07ebfa1
KZ
53.RS
54.TP
fd6b7a7f
KZ
55.I n
56where
57.I n
2085ba6c 58is larger than 0. The process with PID
fd6b7a7f 59.I n
83098262 60is signaled.
c07ebfa1
KZ
61.TP
62.B 0
63All processes in the current process group are signaled.
64.TP
1c4c6024 65.B \-1
2085ba6c 66All processes with a PID larger than 1 are signaled.
c07ebfa1 67.TP
1c4c6024 68.BI \- n
b0315e1f
PB
69where
70.I n
9e068ce0 71is larger than 1. All processes in process group
fd6b7a7f 72.I n
1c4c6024 73are signaled. When an argument of the form '\-n' is given, and it is meant to
83098262 74denote a process group, either a signal must be specified first, or the
1c4c6024 75argument must be preceded by a '\-\-' option, otherwise it will be taken as the
9e068ce0 76signal to send.
10ab72e7 77.RE
c07ebfa1 78.TP
10ab72e7 79.I name
83098262
BS
80All processes invoked using this \fIname\fR will be signaled.
81
82.SH OPTIONS
6dbe3af9 83.TP
9e068ce0 84\fB\-s\fR, \fB\-\-signal\fR \fIsignal\fR
83098262 85The signal to send. It may be given as a name or a number.
6dbe3af9 86.TP
83098262
BS
87\fB\-l\fR, \fB\-\-list\fR [\fInumber\fR]
88Print a list of signal names, or convert the given signal number to a name.
89The signals can be found in
9e068ce0 90.I /usr/\:include/\:linux/\:signal.h
c07ebfa1 91.TP
fda84b66 92\fB\-L\fR, \fB\-\-table\fR
83098262 93Similar to \fB\-l\fR, but it will print signal names and their corresponding
fda84b66
SK
94numbers.
95.TP
9e068ce0 96\fB\-a\fR, \fB\-\-all\fR
2085ba6c 97Do not restrict the command-name-to-PID conversion to processes with the same
a72fa61a 98UID as the present process.
c07ebfa1 99.TP
9e068ce0 100\fB\-p\fR, \fB\-\-pid\fR
2085ba6c 101Only print the process ID (PID) of the named processes, do not send any
9e068ce0 102signals.
a1504d8b 103.TP
1c23b1c5 104\fB\-\-verbose\fR
2085ba6c 105Print PID(s) that will be signaled with kill along with the signal.
1c23b1c5 106.TP
83098262 107\fB\-q\fR, \fB\-\-queue\fR \fIvalue\fR
a1504d8b 108Use
b79cc53b 109.BR sigqueue (3)
a1504d8b 110rather than
83098262
BS
111.BR kill (2).
112The
113.I value
114argument is an integer that is sent along with the signal. If the
d9818c9b
MK
115receiving process has installed a handler for this signal using the
116.B SA_SIGINFO
9e068ce0 117flag to
a1504d8b 118.BR sigaction (2),
d9818c9b
MK
119then it can obtain this data via the
120.I si_sigval
121field of the
122.I siginfo_t
123structure.
6e6b9a1d
SK
124.TP
125\fB\-\-timeout\fR \fImilliseconds signal\fR
126Send a signal defined the usual way to a process.
127.B \-\-timeout
128will make
129.B kill
130to wait for a period defined in
131.I milliseconds
132before sending follow-up
133.I signal
1395236a
KZ
134to process.
135This feature is implemented by PID file-descriptor and guaranties that
136follow-up signals are sent to the same process or not sent if the process no
137more exist. Note that the operating system may re-use PIDs and implement the
138same feature in a shell by kill and sleep commands sequence may introduce a
139race. This option can be specified more than once than signals are sent
140sequentially in defined timeouts. The
6e6b9a1d
SK
141.B \-\-timeout
142option can be combined with
143.B \-\-queue
144option.
145.IP
1395236a
KZ
146Example. Send signals QUIT, TERM and KILL in sequence and wait for 1000
147milliseconds between the signals
6e6b9a1d 148.br
1c4c6024 149kill \-\-verbose \-\-timeout 1000 TERM \-\-timeout 1000 KILL \-\-signal QUIT 12345
67e63c12
MK
150.SH EXIT STATUS
151.B kill
152has the following exit status values:
153.PP
154.RS
155.PD 0
156.TP
157.B 0
158success
159.TP
160.B 1
161failure
162.TP
163.B 64
164partial success (when more than one process specified)
165.PD
166.RE
741587f3 167.SH NOTES
f793f8bc 168Although it is possible to specify the TID (thread ID, see
741587f3 169.BR gettid (2))
f793f8bc
MK
170of one of the threads in a multithreaded process as the argument of
171.BR kill ,
172the signal is nevertheless directed to the process
173(i.e., the entire thread group).
174In other words, it is not possible to send a signal to an
175explicitly selected thread in a multithreaded process.
176The signal will be delivered to an arbitrarily selected thread
177in the target process that is not blocking the signal.
178For more details, see
179.BR signal (7)
180and the description of
0bb7e904 181.B CLONE_THREAD
f793f8bc
MK
182in
183.BR clone (2).
735fd5ed
SK
184.P
185Various shells have provide an internal kill implementation that is
186preferred in relation to the
187.BR kill (1)
188executable described by this manual. Easiest way to ensure one is executing
189the executable is to use full path when calling the command, for example:
c5178f27 190.B "/bin/kill \-\-version"
6853d664 191.SH AUTHORS
9e068ce0
SK
192.MT svalente@mit.edu
193Salvatore Valente
6853d664
KZ
194.ME
195.br
196.MT kzak@redhat.com
197Karel Zak
198.ME
199.br
200.PP
201The original version was taken from BSD 4.4.
202
ade04bb8
MK
203.SH SEE ALSO
204.BR bash (1),
205.BR tcsh (1),
206.BR sigaction (2),
207.BR kill (2),
208.BR sigqueue (3),
209.BR signal (7)
210
86d62711 211.SH AVAILABILITY
601d12fb 212The kill command is part of the util-linux package and is available from
d673b74e 213.UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/
9e068ce0
SK
214Linux Kernel Archive
215.UE .