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