]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" Modified by Michael Haardt <michael@moria.de> | |
26 | .\" Modified by Thomas Koenig <ig25@rz.uni-karlsruhe.de> | |
27 | .\" Modified 1993-07-23 by Rik Faith <faith@cs.unc.edu> | |
28 | .\" Modified 1993-07-25 by Rik Faith <faith@cs.unc.edu> | |
29 | .\" Modified 1995-11-01 by Michael Haardt | |
30 | .\" <michael@cantor.informatik.rwth-aachen.de> | |
31 | .\" Modified 1996-04-14 by Andries Brouwer <aeb@cwi.nl> | |
32 | .\" [added some polishing contributed by Mike Battersby <mib@deakin.edu.au>] | |
33 | .\" Modified 1996-07-21 by Andries Brouwer <aeb@cwi.nl> | |
34 | .\" Modified 1997-01-17 by Andries Brouwer <aeb@cwi.nl> | |
35 | .\" Modified 2001-12-18 by Andries Brouwer <aeb@cwi.nl> | |
c11b1abf | 36 | .\" Modified 2002-07-24 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da MK |
37 | .\" Added note on historical rules enforced when an unprivileged process |
38 | .\" sends a signal. | |
c11b1abf | 39 | .\" Modified 2004-06-16 by Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da MK |
40 | .\" Added note on CAP_KILL |
41 | .\" Modified 2004-06-24 by aeb | |
7f325695 | 42 | .\" Modified, 2004-11-30, after idea from emmanuel.colbus@ensimag.imag.fr |
fea681da | 43 | .\" |
3df541c0 | 44 | .TH KILL 2 2016-07-17 "Linux" "Linux Programmer's Manual" |
fea681da MK |
45 | .SH NAME |
46 | kill \- send signal to a process | |
47 | .SH SYNOPSIS | |
48 | .nf | |
49 | .B #include <sys/types.h> | |
50 | .br | |
51 | .B #include <signal.h> | |
52 | .sp | |
53 | .BI "int kill(pid_t " pid ", int " sig ); | |
54 | .fi | |
cc4615cc MK |
55 | .sp |
56 | .in -4n | |
57 | Feature Test Macro Requirements for glibc (see | |
58 | .BR feature_test_macros (7)): | |
59 | .in | |
60 | .sp | |
0f200f07 | 61 | .ad l |
cc4615cc | 62 | .BR kill (): |
cff459de | 63 | _POSIX_C_SOURCE |
0f200f07 | 64 | .ad b |
fea681da MK |
65 | .SH DESCRIPTION |
66 | The | |
e511ffb6 | 67 | .BR kill () |
fea681da MK |
68 | system call |
69 | can be used to send any signal to any process group or process. | |
70 | .PP | |
0527ad7f MK |
71 | If \fIpid\fP is positive, then signal \fIsig\fP is sent to the |
72 | process with the ID specified by \fIpid\fP. | |
fea681da MK |
73 | .PP |
74 | If \fIpid\fP equals 0, then \fIsig\fP is sent to every process in the | |
a1ffe9f5 | 75 | process group of the calling process. |
fea681da | 76 | .PP |
30e6794a | 77 | If \fIpid\fP equals \-1, then \fIsig\fP is sent to every process |
cbc84c6e | 78 | for which the calling process has permission to send signals, |
7c1bc63f | 79 | except for process 1 (\fIinit\fP), but see below. |
fea681da MK |
80 | .PP |
81 | If \fIpid\fP is less than \-1, then \fIsig\fP is sent to every process | |
0527ad7f | 82 | in the process group whose ID is \fI\-pid\fP. |
fea681da | 83 | .PP |
a9562222 MK |
84 | If \fIsig\fP is 0, then no signal is sent, |
85 | but existence and permission checks are still performed; | |
0527ad7f | 86 | this can be used to check for the existence of a process ID or |
a9562222 | 87 | process group ID that the caller is permitted to signal. |
fea681da MK |
88 | |
89 | For a process to have permission to send a signal | |
90 | it must either be privileged (under Linux: have the | |
91 | .B CAP_KILL | |
92 | capability), or the real or effective | |
93 | user ID of the sending process must equal the real or | |
94 | saved set-user-ID of the target process. | |
8bd58774 MK |
95 | In the case of |
96 | .B SIGCONT | |
97 | it suffices when the sending and receiving | |
fea681da | 98 | processes belong to the same session. |
9e3859ed | 99 | (Historically, the rules were different; see NOTES.) |
47297adb | 100 | .SH RETURN VALUE |
fea681da MK |
101 | On success (at least one signal was sent), zero is returned. |
102 | On error, \-1 is returned, and | |
103 | .I errno | |
104 | is set appropriately. | |
105 | .SH ERRORS | |
106 | .TP | |
107 | .B EINVAL | |
108 | An invalid signal was specified. | |
109 | .TP | |
110 | .B EPERM | |
111 | The process does not have permission to send the signal | |
112 | to any of the target processes. | |
113 | .TP | |
114 | .B ESRCH | |
115 | The pid or process group does not exist. | |
116 | Note that an existing process might be a zombie, | |
117 | a process which already committed termination, but | |
60a90ecd MK |
118 | has not yet been |
119 | .BR wait (2)ed | |
120 | for. | |
47297adb | 121 | .SH CONFORMING TO |
80f75fab | 122 | POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. |
fea681da | 123 | .SH NOTES |
f92154be | 124 | The only signals that can be sent to process ID 1, the |
7f325695 MK |
125 | .I init |
126 | process, are those for which | |
127 | .I init | |
128 | has explicitly installed signal handlers. | |
129 | This is done to assure the | |
fea681da MK |
130 | system is not brought down accidentally. |
131 | .LP | |
80f75fab | 132 | POSIX.1 requires that \fIkill(\-1,sig)\fP send \fIsig\fP |
a1ffe9f5 | 133 | to all processes that the calling process may send signals to, |
fea681da MK |
134 | except possibly for some implementation-defined system processes. |
135 | Linux allows a process to signal itself, but on Linux the call | |
a1ffe9f5 | 136 | \fIkill(\-1,sig)\fP does not signal the calling process. |
fea681da | 137 | .LP |
80f75fab | 138 | POSIX.1 requires that if a process sends a signal to itself, |
c13182ef | 139 | and the sending thread does not have the signal blocked, |
cbea10b3 | 140 | and no other thread |
988db661 | 141 | has it unblocked or is waiting for it in |
d9c1ae64 MK |
142 | .BR sigwait (3), |
143 | at least one | |
fea681da | 144 | unblocked signal must be delivered to the sending thread before the |
3392d76d MK |
145 | .BR kill () |
146 | returns. | |
73d8cece | 147 | .SS Linux notes |
fea681da MK |
148 | Across different kernel versions, Linux has enforced different rules |
149 | for the permissions required for an unprivileged process | |
150 | to send a signal to another process. | |
151 | .\" In the 0.* kernels things chopped and changed quite | |
152 | .\" a bit - MTK, 24 Jul 02 | |
153 | In kernels 1.0 to 1.2.2, a signal could be sent if the | |
9e3859ed MK |
154 | effective user ID of the sender matched effective user ID of the target, |
155 | or the real user ID of the sender matched the real user ID of the target. | |
fea681da MK |
156 | From kernel 1.2.3 until 1.3.77, a signal could be sent if the |
157 | effective user ID of the sender matched either the real or effective | |
9e3859ed | 158 | user ID of the target. |
80f75fab | 159 | The current rules, which conform to POSIX.1, were adopted |
fea681da | 160 | in kernel 1.3.78. |
cc171723 MK |
161 | .SH BUGS |
162 | In 2.6 kernels up to and including 2.6.7, | |
163 | there was a bug that meant that when sending signals to a process group, | |
164 | .BR kill () | |
165 | failed with the error | |
166 | .B EPERM | |
b57b23a5 | 167 | if the caller did not have permission to send the signal to \fIany\fP (rather |
cc171723 MK |
168 | than \fIall\fP) of the members of the process group. |
169 | Notwithstanding this error return, the signal was still delivered | |
170 | to all of the processes for which the caller had permission to signal. | |
47297adb | 171 | .SH SEE ALSO |
fea681da MK |
172 | .BR _exit (2), |
173 | .BR killpg (2), | |
174 | .BR signal (2), | |
175 | .BR tkill (2), | |
176 | .BR exit (3), | |
485ab701 | 177 | .BR sigqueue (3), |
fea681da | 178 | .BR capabilities (7), |
53a1443c | 179 | .BR credentials (7), |
fea681da | 180 | .BR signal (7) |