Commit | Line | Data |
---|---|---|
fd335675 KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
3fa31615 | 5 | .\" @(#)kill.2 6.5 (Berkeley) %G% |
fd335675 | 6 | .\" |
00d519a0 | 7 | .TH KILL 2 "" |
fd335675 KM |
8 | .UC 4 |
9 | .SH NAME | |
10 | kill \- send signal to a process | |
11 | .SH SYNOPSIS | |
5a815050 KM |
12 | .ft B |
13 | kill(pid, sig) | |
14 | .br | |
15 | int pid, sig; | |
fd335675 KM |
16 | .SH DESCRIPTION |
17 | .I Kill | |
5a815050 KM |
18 | sends the signal \fIsig\fP |
19 | to a process, specified by the process number | |
20 | .IR pid . | |
21 | .I Sig | |
22 | may be one of the signals specified in | |
23 | .IR sigvec (2), | |
24 | or it may be 0, in which case | |
25 | error checking is performed but no | |
26 | signal is actually sent. | |
27 | This can be used to check the validity of | |
28 | .IR pid . | |
fd335675 KM |
29 | .PP |
30 | The sending and receiving processes must | |
31 | have the same effective user ID, otherwise | |
32 | this call is restricted to the super-user. | |
41d37740 | 33 | A single exception is the signal SIGCONT, which may always be sent |
3fa31615 | 34 | to any descendant of the current process. |
fd335675 KM |
35 | .PP |
36 | If the process number is 0, | |
d6abbb8b | 37 | the signal is sent to all processes in the |
5a815050 | 38 | sender's process group; this is a variant of |
fd335675 KM |
39 | .IR killpg (2). |
40 | .PP | |
d6abbb8b | 41 | If the process number is \-1 |
e3c05138 | 42 | and the user is the super-user, |
fd335675 | 43 | the signal is broadcast universally |
5a815050 | 44 | except to system processes |
fd335675 | 45 | and the process sending the signal. |
d6abbb8b | 46 | If the process number is \-1 |
e3c05138 KM |
47 | and the user is not the super-user, |
48 | the signal is broadcast universally to | |
49 | all processes with the same uid as the user | |
50 | except the process sending the signal. | |
3fa31615 | 51 | No error is returned if any process could be signaled. |
e3c05138 KM |
52 | .PP |
53 | For compatibility with System V, | |
d6abbb8b JL |
54 | if the process number is negative but not \-1, |
55 | the signal is sent to all processes whose process group ID | |
e3c05138 KM |
56 | is equal to the absolute value of the process number. |
57 | This is a variant of | |
58 | .IR killpg (2). | |
fd335675 KM |
59 | .PP |
60 | Processes may send signals to themselves. | |
5a815050 KM |
61 | .SH "RETURN VALUE |
62 | Upon successful completion, a value of 0 is returned. | |
63 | Otherwise, a value of \-1 is returned and | |
64 | .I errno | |
65 | is set to indicate the error. | |
66 | .SH "ERRORS | |
67 | .I Kill | |
68 | will fail and no signal will be sent if any of the following | |
69 | occur: | |
70 | .TP 15 | |
71 | [EINVAL] | |
72 | \fISig\fP is not a valid signal number. | |
73 | .TP 15 | |
74 | [ESRCH] | |
75 | No process can be found corresponding to that specified by \fIpid\fP. | |
76 | .TP 15 | |
3fa31615 MK |
77 | [ESRCH] |
78 | The process id was given as 0 | |
79 | but the sending process does not have a process group. | |
80 | .TP 15 | |
5a815050 KM |
81 | [EPERM] |
82 | The sending process is not the super-user and its effective | |
83 | user id does not match the effective user-id of the receiving process. | |
3fa31615 MK |
84 | When signaling a process group, this error was returned if any members |
85 | of the group could not be signaled. | |
fd335675 | 86 | .SH "SEE ALSO" |
5a815050 | 87 | getpid(2), getpgrp(2), killpg(2), sigvec(2) |