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