]>
Commit | Line | Data |
---|---|---|
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 |
6 | kill \- 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 | 22 | The command |
6dbe3af9 | 23 | .B kill |
83098262 | 24 | sends the specified \fIsignal\fR to the specified processes or process groups. |
3d463c67 MK |
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 | |
8419465d | 35 | to perform any clean-up before terminating. |
c07ebfa1 | 36 | .PP |
226c38d4 MK |
37 | Most modern shells have a builtin |
38 | .B kill | |
39 | command, with a usage rather similar to | |
83098262 BS |
40 | that of the command described here. The |
41 | .BR \-\-all , | |
42 | .BR \-\-pid ", and" | |
0bb7e904 | 43 | .B \-\-queue |
83098262 | 44 | options, and the possibility to specify processes by command name, are local extensions. |
bd0fb63d | 45 | .PP |
83098262 BS |
46 | If \fIsignal\fR is 0, then no actual signal is sent, but error checking is still performed. |
47 | ||
48 | .SH ARGUMENTS | |
2085ba6c | 49 | The list of processes to be signaled can be a mixture of names and PIDs. |
6dbe3af9 | 50 | .TP |
83098262 BS |
51 | .I pid |
52 | Each | |
6dbe3af9 | 53 | .I pid |
226c38d4 | 54 | can be expressed in one of the following ways: |
c07ebfa1 KZ |
55 | .RS |
56 | .TP | |
fd6b7a7f KZ |
57 | .I n |
58 | where | |
59 | .I n | |
2085ba6c | 60 | is larger than 0. The process with PID |
fd6b7a7f | 61 | .I n |
83098262 | 62 | is signaled. |
c07ebfa1 KZ |
63 | .TP |
64 | .B 0 | |
65 | All processes in the current process group are signaled. | |
66 | .TP | |
1c4c6024 | 67 | .B \-1 |
2085ba6c | 68 | All processes with a PID larger than 1 are signaled. |
c07ebfa1 | 69 | .TP |
1c4c6024 | 70 | .BI \- n |
b0315e1f PB |
71 | where |
72 | .I n | |
9e068ce0 | 73 | is larger than 1. All processes in process group |
fd6b7a7f | 74 | .I n |
1c4c6024 | 75 | are signaled. When an argument of the form '\-n' is given, and it is meant to |
83098262 | 76 | denote a process group, either a signal must be specified first, or the |
1c4c6024 | 77 | argument must be preceded by a '\-\-' option, otherwise it will be taken as the |
9e068ce0 | 78 | signal to send. |
10ab72e7 | 79 | .RE |
c07ebfa1 | 80 | .TP |
10ab72e7 | 81 | .I name |
83098262 BS |
82 | All processes invoked using this \fIname\fR will be signaled. |
83 | ||
84 | .SH OPTIONS | |
6dbe3af9 | 85 | .TP |
9e068ce0 | 86 | \fB\-s\fR, \fB\-\-signal\fR \fIsignal\fR |
83098262 | 87 | The signal to send. It may be given as a name or a number. |
6dbe3af9 | 88 | .TP |
83098262 BS |
89 | \fB\-l\fR, \fB\-\-list\fR [\fInumber\fR] |
90 | Print a list of signal names, or convert the given signal number to a name. | |
91 | The signals can be found in | |
226c38d4 | 92 | .IR /usr/\:include/\:linux/\:signal.h . |
c07ebfa1 | 93 | .TP |
fda84b66 | 94 | \fB\-L\fR, \fB\-\-table\fR |
83098262 | 95 | Similar to \fB\-l\fR, but it will print signal names and their corresponding |
fda84b66 SK |
96 | numbers. |
97 | .TP | |
9e068ce0 | 98 | \fB\-a\fR, \fB\-\-all\fR |
2085ba6c | 99 | Do not restrict the command-name-to-PID conversion to processes with the same |
a72fa61a | 100 | UID as the present process. |
c07ebfa1 | 101 | .TP |
9e068ce0 | 102 | \fB\-p\fR, \fB\-\-pid\fR |
2085ba6c | 103 | Only print the process ID (PID) of the named processes, do not send any |
9e068ce0 | 104 | signals. |
a1504d8b | 105 | .TP |
1c23b1c5 | 106 | \fB\-\-verbose\fR |
226c38d4 MK |
107 | Print PID(s) that will be signaled with |
108 | .B kill | |
109 | along with the signal. | |
1c23b1c5 | 110 | .TP |
83098262 | 111 | \fB\-q\fR, \fB\-\-queue\fR \fIvalue\fR |
226c38d4 | 112 | Send the signal using |
b79cc53b | 113 | .BR sigqueue (3) |
a1504d8b | 114 | rather than |
83098262 BS |
115 | .BR kill (2). |
116 | The | |
117 | .I value | |
118 | argument is an integer that is sent along with the signal. If the | |
d9818c9b MK |
119 | receiving process has installed a handler for this signal using the |
120 | .B SA_SIGINFO | |
9e068ce0 | 121 | flag to |
a1504d8b | 122 | .BR sigaction (2), |
d9818c9b MK |
123 | then it can obtain this data via the |
124 | .I si_sigval | |
125 | field of the | |
126 | .I siginfo_t | |
127 | structure. | |
6e6b9a1d SK |
128 | .TP |
129 | \fB\-\-timeout\fR \fImilliseconds signal\fR | |
a374630f MK |
130 | Send a signal defined in the usual way to a process, |
131 | followed by an additional signal after a specified delay. | |
132 | The | |
6e6b9a1d | 133 | .B \-\-timeout |
a374630f | 134 | option causes |
6e6b9a1d SK |
135 | .B kill |
136 | to wait for a period defined in | |
137 | .I milliseconds | |
a374630f | 138 | before sending a follow-up |
6e6b9a1d | 139 | .I signal |
a374630f MK |
140 | to the process. |
141 | This feature is implemented using the Linux kernel | |
142 | PID file descriptor feature in order to guarantee that the follow-up signal | |
143 | is sent to the same process or not sent if the process no longer exists. | |
144 | .IP | |
145 | Note that the operating system may re-use PIDs and implementing an | |
146 | equivalent feature in a shell using | |
147 | .B kill | |
148 | and | |
149 | .B sleep | |
150 | would be subject to races whereby the follow-up signal might be sent | |
151 | to a different process that used a recycled PID. | |
152 | .IP | |
153 | The | |
154 | .B \-\-timeout | |
155 | option can be specified multiple times: the signals are sent | |
156 | sequentially with the specified timeouts. The | |
6e6b9a1d | 157 | .B \-\-timeout |
a374630f | 158 | option can be combined with the |
6e6b9a1d SK |
159 | .B \-\-queue |
160 | option. | |
161 | .IP | |
a374630f MK |
162 | As an example, the following command sends |
163 | the signals QUIT, TERM and KILL in sequence and waits for 1000 | |
164 | milliseconds between sending the signals: | |
165 | .IP | |
166 | .in +4n | |
167 | .EE | |
168 | kill \-\-verbose \-\-timeout 1000 TERM \-\-timeout 1000 KILL \e | |
169 | \-\-signal QUIT 12345 | |
170 | .EE | |
171 | .in | |
67e63c12 MK |
172 | .SH EXIT STATUS |
173 | .B kill | |
174 | has the following exit status values: | |
175 | .PP | |
176 | .RS | |
177 | .PD 0 | |
178 | .TP | |
179 | .B 0 | |
180 | success | |
181 | .TP | |
182 | .B 1 | |
183 | failure | |
184 | .TP | |
185 | .B 64 | |
186 | partial success (when more than one process specified) | |
187 | .PD | |
188 | .RE | |
741587f3 | 189 | .SH NOTES |
f793f8bc | 190 | Although it is possible to specify the TID (thread ID, see |
741587f3 | 191 | .BR gettid (2)) |
f793f8bc MK |
192 | of one of the threads in a multithreaded process as the argument of |
193 | .BR kill , | |
194 | the signal is nevertheless directed to the process | |
195 | (i.e., the entire thread group). | |
196 | In other words, it is not possible to send a signal to an | |
197 | explicitly selected thread in a multithreaded process. | |
198 | The signal will be delivered to an arbitrarily selected thread | |
199 | in the target process that is not blocking the signal. | |
200 | For more details, see | |
201 | .BR signal (7) | |
202 | and the description of | |
0bb7e904 | 203 | .B CLONE_THREAD |
f793f8bc MK |
204 | in |
205 | .BR clone (2). | |
735fd5ed | 206 | .P |
226c38d4 MK |
207 | Various shells provide a builtin |
208 | .B kill | |
209 | command that is | |
735fd5ed SK |
210 | preferred in relation to the |
211 | .BR kill (1) | |
226c38d4 MK |
212 | executable described by this manual. |
213 | The easiest way to ensure one is executing the command described in this page | |
214 | is to use the full path when calling the command, for example: | |
c5178f27 | 215 | .B "/bin/kill \-\-version" |
6853d664 | 216 | .SH AUTHORS |
9e068ce0 SK |
217 | .MT svalente@mit.edu |
218 | Salvatore Valente | |
6853d664 KZ |
219 | .ME |
220 | .br | |
221 | .MT kzak@redhat.com | |
222 | Karel Zak | |
223 | .ME | |
224 | .br | |
225 | .PP | |
226 | The original version was taken from BSD 4.4. | |
227 | ||
ade04bb8 MK |
228 | .SH SEE ALSO |
229 | .BR bash (1), | |
230 | .BR tcsh (1), | |
231 | .BR sigaction (2), | |
232 | .BR kill (2), | |
233 | .BR sigqueue (3), | |
234 | .BR signal (7) | |
235 | ||
86d62711 | 236 | .SH AVAILABILITY |
601d12fb | 237 | The kill command is part of the util-linux package and is available from |
d673b74e | 238 | .UR https://\:www.kernel.org\:/pub\:/linux\:/utils\:/util-linux/ |
9e068ce0 SK |
239 | Linux Kernel Archive |
240 | .UE . |