Commit | Line | Data |
---|---|---|
aaea5b2e KB |
1 | .\" Copyright (c) 1980, 1991, 1993 |
2 | .\" The Regents of the University of California. All rights reserved. | |
fd335675 | 3 | .\" |
931b8415 | 4 | .\" %sccs.include.redist.man% |
fd335675 | 5 | .\" |
aaea5b2e | 6 | .\" @(#)kill.2 8.1 (Berkeley) %G% |
931b8415 CL |
7 | .\" |
8 | .Dd | |
9 | .Dt KILL 2 | |
10 | .Os BSD 4 | |
11 | .Sh NAME | |
12 | .Nm kill | |
13 | .Nd send signal to a process | |
14 | .Sh SYNOPSIS | |
4add9a99 | 15 | .Fd #include <signal.h> |
931b8415 CL |
16 | .Ft int |
17 | .Fn kill "pid_t pid" "int sig" | |
18 | .Sh DESCRIPTION | |
19 | The | |
20 | .Fn kill | |
21 | function sends the signal given by | |
22 | .Fa sig | |
23 | to | |
24 | .Fa pid , | |
25 | a | |
26 | process or a group of processes. | |
27 | .Fa Sig | |
5a815050 | 28 | may be one of the signals specified in |
931b8415 | 29 | .Xr sigaction 2 |
5a815050 KM |
30 | or it may be 0, in which case |
31 | error checking is performed but no | |
32 | signal is actually sent. | |
33 | This can be used to check the validity of | |
931b8415 CL |
34 | .Fa pid . |
35 | .Pp | |
36 | For a process to have permission to send a signal to a process designated | |
37 | by | |
38 | .Fa pid , | |
39 | the real or effective user ID of the receving process must match | |
40 | that of the sending process or the user must have appropriate privileges | |
41 | (such as given by a set-user-ID program or the user is the super-user). | |
41d37740 | 42 | A single exception is the signal SIGCONT, which may always be sent |
3fa31615 | 43 | to any descendant of the current process. |
931b8415 CL |
44 | .Bl -tag -width Ds |
45 | .It \&If Fa pid No \&is greater than zero : | |
46 | .Fa Sig | |
47 | is sent to the process whose ID is equal to | |
48 | .Fa pid. | |
49 | .It \&If Fa pid No \&is zero : | |
50 | .Fa Sig | |
51 | is sent to all processes whose group ID is equal | |
52 | to the process group ID of the sender, and for which the | |
53 | process has permission; | |
54 | this is a variant of | |
55 | .Xr killpg 2 . | |
56 | .It \&If Fa pid No \&is -1 : | |
57 | If the user has super user privileges, | |
58 | the signal is sent to all processes excluding | |
2eea54dc KB |
59 | system processes and the process sending the signal. |
60 | If the user is not the super user, the signal is sent to all processes | |
61 | with the same uid as the user excluding the process sending the signal. | |
3fa31615 | 62 | No error is returned if any process could be signaled. |
931b8415 CL |
63 | .El |
64 | .Pp | |
e3c05138 | 65 | For compatibility with System V, |
931b8415 | 66 | if the process number is negative but not -1, |
d6abbb8b | 67 | the signal is sent to all processes whose process group ID |
e3c05138 KM |
68 | is equal to the absolute value of the process number. |
69 | This is a variant of | |
931b8415 CL |
70 | .Xr killpg 2 . |
71 | .Sh RETURN VALUES | |
5a815050 | 72 | Upon successful completion, a value of 0 is returned. |
931b8415 CL |
73 | Otherwise, a value of -1 is returned and |
74 | .Va errno | |
5a815050 | 75 | is set to indicate the error. |
931b8415 CL |
76 | .Sh ERRORS |
77 | .Fn Kill | |
78 | will fail and no signal will be sent if: | |
79 | .Bl -tag -width [EINVAL] | |
80 | .It Bq Er EINVAL | |
81 | .Fa Sig | |
82 | is not a valid signal number. | |
83 | .It Bq Er ESRCH | |
84 | No process can be found corresponding to that specified by | |
85 | .Fa pid . | |
86 | .It Bq Er ESRCH | |
3fa31615 MK |
87 | The process id was given as 0 |
88 | but the sending process does not have a process group. | |
931b8415 | 89 | .It Bq Er EPERM |
5a815050 KM |
90 | The sending process is not the super-user and its effective |
91 | user id does not match the effective user-id of the receiving process. | |
931b8415 | 92 | When signaling a process group, this error is returned if any members |
3fa31615 | 93 | of the group could not be signaled. |
931b8415 CL |
94 | .El |
95 | .Sh SEE ALSO | |
96 | .Xr getpid 2 , | |
97 | .Xr getpgrp 2 , | |
98 | .Xr killpg 2 , | |
99 | .Xr sigaction 2 | |
100 | .Sh STANDARDS | |
101 | The | |
102 | .Fn kill | |
103 | function is expected to | |
104 | conform to IEEE Std 1003.1-1988 | |
105 | .Pq Dq Tn POSIX . |