1KILL(1) User Commands KILL(1)
2
3
4
6 kill - terminate a process
7
9 kill [-signal|-s signal|-p] [-q value] [-a] [--timeout milliseconds
10 signal] [--] pid|name...
11 kill -l [number] | -L
12
14 The command kill sends the specified signal to the specified processes
15 or process groups.
16
17 If no signal is specified, the TERM signal is sent. The default action
18 for this signal is to terminate the process. This signal should be
19 used in preference to the KILL signal (number 9), since a process may
20 install a handler for the TERM signal in order to perform clean-up
21 steps before terminating in an orderly fashion. If a process does not
22 terminate after a TERM signal has been sent, then the KILL signal may
23 be used; be aware that the latter signal cannot be caught, and so does
24 not give the target process the opportunity to perform any clean-up
25 before terminating.
26
27 Most modern shells have a builtin kill command, with a usage rather
28 similar to that of the command described here. The --all, --pid, and
29 --queue options, and the possibility to specify processes by command
30 name, are local extensions.
31
32 If signal is 0, then no actual signal is sent, but error checking is
33 still performed.
34
35
37 The list of processes to be signaled can be a mixture of names and
38 PIDs.
39
40 pid Each pid can be one of four things:
41
42 n where n is larger than 0. The process with PID n is sig‐
43 naled.
44
45 0 All processes in the current process group are signaled.
46
47 -1 All processes with a PID larger than 1 are signaled.
48
49 -n where n is larger than 1. All processes in process group
50 n are signaled. When an argument of the form '-n' is
51 given, and it is meant to denote a process group, either
52 a signal must be specified first, or the argument must be
53 preceded by a '--' option, otherwise it will be taken as
54 the signal to send.
55
56 name All processes invoked using this name will be signaled.
57
58
60 -s, --signal signal
61 The signal to send. It may be given as a name or a number.
62
63 -l, --list [number]
64 Print a list of signal names, or convert the given signal number
65 to a name. The signals can be found in /usr/include/linux/sig‐
66 nal.h
67
68 -L, --table
69 Similar to -l, but it will print signal names and their corre‐
70 sponding numbers.
71
72 -a, --all
73 Do not restrict the command-name-to-PID conversion to processes
74 with the same UID as the present process.
75
76 -p, --pid
77 Only print the process ID (PID) of the named processes, do not
78 send any signals.
79
80 --verbose
81 Print PID(s) that will be signaled with kill along with the sig‐
82 nal.
83
84 -q, --queue value
85 Use sigqueue(3) rather than kill(2). The value argument is an
86 integer that is sent along with the signal. If the receiving
87 process has installed a handler for this signal using the
88 SA_SIGINFO flag to sigaction(2), then it can obtain this data
89 via the si_sigval field of the siginfo_t structure.
90
91 --timeout milliseconds signal
92 Send a signal defined the usual way to a process. --timeout
93 will make kill to wait for a period defined in milliseconds
94 before sending follow-up signal to process. This feature is
95 implemented by PID file-descriptor and guaranties that follow-up
96 signals are sent to the same process or not sent if the process
97 no more exist. Note that the operating system may re-use PIDs
98 and implement the same feature in a shell by kill and sleep com‐
99 mands sequence may introduce a race. This option can be speci‐
100 fied more than once than signals are sent sequentially in
101 defined timeouts. The --timeout option can be combined with
102 --queue option.
103
104 Example. Send signals QUIT, TERM and KILL in sequence and wait
105 for 1000 milliseconds between the signals
106 kill --verbose --timeout 1000 TERM --timeout 1000 KILL --signal
107 QUIT 12345
108
110 Although it is possible to specify the TID (thread ID, see gettid(2))
111 of one of the threads in a multithreaded process as the argument of
112 kill, the signal is nevertheless directed to the process (i.e., the
113 entire thread group). In other words, it is not possible to send a
114 signal to an explicitly selected thread in a multithreaded process.
115 The signal will be delivered to an arbitrarily selected thread in the
116 target process that is not blocking the signal. For more details, see
117 signal(7) and the description of CLONE_THREAD in clone(2).
118
119
121 kill has the following return codes:
122
123 0 success
124
125 1 failure
126
127 64 partial success (when more than one process specified)
128
129
131 bash(1), tcsh(1), sigaction(2), kill(2), sigqueue(3), signal(7)
132
133
135 Salvatore Valente ⟨svalente@mit.edu⟩
136 Karel Zak ⟨kzak@redhat.com⟩
137
138 The original version was taken from BSD 4.4.
139
140
142 The kill command is part of the util-linux package and is available
143 from Linux Kernel Archive ⟨https://www.kernel.org/pub/linux/utils/util-
144 linux/⟩.
145
146
147
148util-linux November 2019 KILL(1)