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