]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/kill.2
Automated unformatting of parentheses using unformat_parens.sh
[thirdparty/man-pages.git] / man2 / kill.2
CommitLineData
fea681da
MK
1.\" Hey Emacs! This file is -*- nroff -*- source.
2.\"
3.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
4.\"
5.\" Permission is granted to make and distribute verbatim copies of this
6.\" manual provided the copyright notice and this permission notice are
7.\" preserved on all copies.
8.\"
9.\" Permission is granted to copy and distribute modified versions of this
10.\" manual under the conditions for verbatim copying, provided that the
11.\" entire resulting derived work is distributed under the terms of a
12.\" permission notice identical to this one.
13.\"
14.\" Since the Linux kernel and libraries are constantly changing, this
15.\" manual page may be incorrect or out-of-date. The author(s) assume no
16.\" responsibility for errors or omissions, or for damages resulting from
17.\" the use of the information contained herein. The author(s) may not
18.\" have taken the same level of care in the production of this manual,
19.\" which is licensed free of charge, as they might when working
20.\" professionally.
21.\"
22.\" Formatted or processed versions of this manual, if unaccompanied by
23.\" the source, must acknowledge the copyright and authors of this work.
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>
305a0578 36.\" Modified 2002-07-24 by Michael Kerrisk <mtk-manpages@gmx.net>
fea681da
MK
37.\" Added note on historical rules enforced when an unprivileged process
38.\" sends a signal.
305a0578 39.\" Modified 2004-06-16 by Michael Kerrisk <mtk-manpages@gmx.net>
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
MK
43.\"
44.TH KILL 2 2004-06-24 "Linux 2.6.7" "Linux Programmer's Manual"
45.SH NAME
46kill \- 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
55.SH DESCRIPTION
56The
e511ffb6 57.BR kill ()
fea681da
MK
58system call
59can be used to send any signal to any process group or process.
60.PP
61If \fIpid\fP is positive, then signal \fIsig\fP is sent to \fIpid\fP.
62.PP
63If \fIpid\fP equals 0, then \fIsig\fP is sent to every process in the
64process group of the current process.
65.PP
30e6794a 66If \fIpid\fP equals \-1, then \fIsig\fP is sent to every process
cbc84c6e 67for which the calling process has permission to send signals,
30e6794a 68except for process 1 (init), but see below.
fea681da
MK
69.PP
70If \fIpid\fP is less than \-1, then \fIsig\fP is sent to every process
71in the process group \fI\-pid\fP.
72.PP
73If \fIsig\fP is 0, then no signal is sent, but error checking is still
74performed.
75
76For a process to have permission to send a signal
77it must either be privileged (under Linux: have the
78.B CAP_KILL
79capability), or the real or effective
80user ID of the sending process must equal the real or
81saved set-user-ID of the target process.
82In the case of SIGCONT it suffices when the sending and receiving
83processes belong to the same session.
84.SH "RETURN VALUE"
85On success (at least one signal was sent), zero is returned.
86On error, \-1 is returned, and
87.I errno
88is set appropriately.
89.SH ERRORS
90.TP
91.B EINVAL
92An invalid signal was specified.
93.TP
94.B EPERM
95The process does not have permission to send the signal
96to any of the target processes.
97.TP
98.B ESRCH
99The pid or process group does not exist.
100Note that an existing process might be a zombie,
101a process which already committed termination, but
63aa9df0 102has not yet been \fBwait\fP()ed for.
fea681da 103.SH NOTES
7f325695
MK
104The only signals that can be sent task number one, the
105.I init
106process, are those for which
107.I init
108has explicitly installed signal handlers.
109This is done to assure the
fea681da
MK
110system is not brought down accidentally.
111.LP
2bc2f479 112POSIX 1003.1-2001 requires that \fIkill(\-1,sig)\fP send \fIsig\fP
fea681da
MK
113to all processes that the current process may send signals to,
114except possibly for some implementation-defined system processes.
115Linux allows a process to signal itself, but on Linux the call
8c383102 116\fIkill(\-1,sig)\fP does not signal the current process.
fea681da
MK
117.LP
118POSIX 1003.1-2003 requires that if a process sends a signal to itself,
119and that process does not have the signal blocked, and no other thread
63aa9df0 120has it unblocked or is waiting for it in \fIsigwait\fP(), at least one
fea681da 121unblocked signal must be delivered to the sending thread before the
63aa9df0 122call of \fIkill\fP() returns.
fea681da
MK
123.SH "LINUX HISTORY"
124Across different kernel versions, Linux has enforced different rules
125for the permissions required for an unprivileged process
126to send a signal to another process.
127.\" In the 0.* kernels things chopped and changed quite
128.\" a bit - MTK, 24 Jul 02
129In kernels 1.0 to 1.2.2, a signal could be sent if the
130effective user ID of the sender matched that of the receiver,
131or the real user ID of the sender matched that of the receiver.
132From kernel 1.2.3 until 1.3.77, a signal could be sent if the
133effective user ID of the sender matched either the real or effective
134user ID of the receiver.
135The current rules, which conform to POSIX 1003.1-2001, were adopted
136in kernel 1.3.78.
137.SH "CONFORMING TO"
b14d4aa5 138SVr4, SVID, POSIX.1, X/OPEN, 4.3BSD, POSIX 1003.1-2001
fea681da
MK
139.SH "SEE ALSO"
140.BR _exit (2),
141.BR killpg (2),
142.BR signal (2),
042d7c1b 143.BR sigqueue (2),
fea681da
MK
144.BR tkill (2),
145.BR exit (3),
146.BR capabilities (7),
147.BR signal (7)