]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/kill.2
bsddialog: import version 1.0
[FreeBSD/FreeBSD.git] / lib / libc / sys / kill.2
1 .\" Copyright (c) 1980, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     @(#)kill.2      8.3 (Berkeley) 4/19/94
29 .\"
30 .Dd December 1, 2019
31 .Dt KILL 2
32 .Os
33 .Sh NAME
34 .Nm kill
35 .Nd send signal to a process
36 .Sh LIBRARY
37 .Lb libc
38 .Sh SYNOPSIS
39 .In sys/types.h
40 .In signal.h
41 .Ft int
42 .Fn kill "pid_t pid" "int sig"
43 .Sh DESCRIPTION
44 The
45 .Fn kill
46 system call sends the signal given by
47 .Fa sig
48 to
49 .Fa pid ,
50 a
51 process or a group of processes.
52 The
53 .Fa sig
54 argument
55 may be one of the signals specified in
56 .Xr sigaction 2
57 or it may be 0, in which case
58 error checking is performed but no
59 signal is actually sent.
60 This can be used to check the validity of
61 .Fa pid .
62 .Pp
63 For a process to have permission to send a signal to a process designated
64 by
65 .Fa pid ,
66 the user must be the super-user, or
67 the real or saved user ID of the receiving process must match
68 the real or effective user ID of the sending process.
69 A single exception is the signal SIGCONT, which may always be sent
70 to any process with the same session ID as the sender.
71 In addition, if the
72 .Va security.bsd.conservative_signals
73 .Xr sysctl 9
74 is set to 1, the user is not a super-user, and
75 the receiver is set-uid, then
76 only job control and terminal control signals may
77 be sent (in particular, only SIGKILL, SIGINT, SIGTERM, SIGALRM,
78 SIGSTOP, SIGTTIN, SIGTTOU, SIGTSTP, SIGHUP, SIGUSR1, SIGUSR2).
79 .Bl -tag -width Ds
80 .It \&If Fa pid No \&is greater than zero :
81 The
82 .Fa sig
83 signal
84 is sent to the process whose ID is equal to
85 .Fa pid .
86 .It \&If Fa pid No \&is zero :
87 The
88 .Fa sig
89 signal
90 is sent to all processes whose group ID is equal
91 to the process group ID of the sender, and for which the
92 process has permission;
93 this is a variant of
94 .Xr killpg 2 .
95 .It \&If Fa pid No \&is -1 :
96 If the user has super-user privileges,
97 the signal is sent to all processes excluding
98 system processes
99 (with
100 .Dv P_SYSTEM
101 flag set),
102 process with ID 1
103 (usually
104 .Xr init 8 ) ,
105 and the process sending the signal.
106 If the user is not the super user, the signal is sent to all processes
107 which the caller has permissions to, excluding the process sending the signal.
108 No error is returned if any process could be signaled.
109 .El
110 .Pp
111 If the process number is negative but not -1,
112 the signal is sent to all processes whose process group ID
113 is equal to the absolute value of the process number.
114 This is a variant of
115 .Xr killpg 2 .
116 .Sh RETURN VALUES
117 .Rv -std kill
118 .Sh ERRORS
119 The
120 .Fn kill
121 system call
122 will fail and no signal will be sent if:
123 .Bl -tag -width Er
124 .It Bq Er EINVAL
125 The
126 .Fa sig
127 argument
128 is not a valid signal number.
129 .It Bq Er ESRCH
130 No process or process group can be found corresponding to that specified by
131 .Fa pid .
132 .It Bq Er EPERM
133 The sending process does not have permission to send
134 .Va sig
135 to any receiving process.
136 .El
137 .Sh SEE ALSO
138 .Xr getpgrp 2 ,
139 .Xr getpid 2 ,
140 .Xr killpg 2 ,
141 .Xr sigaction 2 ,
142 .Xr sigqueue 2 ,
143 .Xr raise 3 ,
144 .Xr init 8
145 .Sh STANDARDS
146 The
147 .Fn kill
148 system call is expected to conform to
149 .St -p1003.1-90 .
150 .Sh HISTORY
151 A version of the
152 .Fn kill
153 function appeared in
154 .At v3 .
155 The signal number was added to the
156 .Fn kill
157 function in
158 .At v4 .