'\"macro stdmacro
.if n .pH g2.kill @(#)kill	40.22 of 10/10/89
.\" Copyright 1989 AT&T
.nr X
.if \nX=0 .ds x} kill 2 "" "\&"
.if \nX=1 .ds x} kill 2 ""
.if \nX=2 .ds x} kill 2 "" "\&"
.if \nX=3 .ds x} kill "" "" "\&"
.TH \*(x}
.SH NAME
\f4kill\f1 \- send a signal to a process or a group of processes
.SH SYNOPSIS
\f4#include <sys/types.h>\f1
.br
\f4#include <signal.h>\f1
.PP
\f4int kill (pid_t pid, int sig);\f1
.SH DESCRIPTION
\f4kill\fP
sends a signal
to a process or a group of processes.
The process or group of
processes to which the signal is to be sent is specified by
.IR pid .
The signal that is to be sent is specified by
.I sig\^
and is either one from the list given in
\f4signal\fP [see \f4signal\fP(5)],
or 0.
If
.I sig\^
is 0 (the null signal), error checking is performed but no signal is
actually sent.
This can be used to check the validity of
.IR pid .
.PP
The real or effective user
.SM ID
of the sending process must match the real or saved
[from exec(2)] user
.SM ID
of the receiving process unless the effective user
.SM ID
of the sending process is superuser, [see \f4intro\fP(2)], or 
\f2sig\f1 is \f4SIGCONT\fP and the sending process has the same session
.SM ID
as the receiving process.
.PP
The process with
.SM ID
0 and the process with
.SM ID
1 are special processes [see
\f4intro\fP(2)]
and will be referred to below as
proc0 and proc1,
respectively.
.PP
If
.I pid\^
is greater than 0,
.I sig\^
will be sent to the process whose process
.SM ID
is equal to 
.IR pid .
.I pid\^
may equal 1.
.PP
If
.I pid\^
is negative but not \f4(pid_t)\-1\fP,
.I sig\^
will be sent to all processes whose process group
.SM ID
is equal to the absolute value of
.I pid
and for which the process has permission to send a signal.
.PP
If
.I pid\^
is \f40\fP,
.I sig\^
will be sent to all processes excluding
proc0 and proc1
whose process group
.SM ID
is equal to the process group
.SM ID
of the sender.
Permission is needed to send a signal to process groups.
.PP
If
.I pid\^
is \f4(pid_t)\-1\fP and the effective user
.SM ID
of the sender is not superuser,
.I sig\^
will be sent to all processes excluding
proc0 and proc1 
whose real user
.SM ID
is equal to the effective user
.SM ID
of the sender.
.PP
If
.I pid\^
is \f4(pid_t)\-1\fP and the effective user
.SM ID
of the sender is superuser,
.I sig\^
will be sent to all processes excluding
proc0 and proc1.
.PP
\f4kill\fP
will fail and no signal will be sent if one or more of the following are true:
.TP 15
\f4EINVAL\fP
.I sig\^
is not a valid signal number.
.TP
\f4EINVAL\fP
\f2sig\f1 is \f4SIGKILL\fP and \f2pid\f1 is \f4(pid_t)1\fP (i.e., \f2pid\fP specifies proc1).
.TP
\f4ESRCH\fP
No process or process group can be found corresponding to that specified by
.IR pid .
.TP
\f4EPERM\fP
The user
.SM ID
of the sending process
is not privileged, and its real or effective user
.SM ID
does not match the real or saved user
.SM ID
of the receiving process, and the calling process is not sending \f4SIGCONT\fP to 
a process that shares the same session \s-1ID\s0.
.SH SEE ALSO
\f4getpid\fP(2), \f4intro\fP(2), \f4setpgrp\fP(2), \f4signal\fP(2), \f4getsid\fP(2), \f4sigsend\fP(2), \f4sigaction\fP(2). 
.sp .2
\f4kill\fP(1) in the
\f2User's Reference Manual\f1.
.SH NOTES
\f4sigsend\fP is a more versatile way to send signals to processes.  The
user is encouraged to use \f4sigsend\fP instead of \f4kill\fP.
.SH DIAGNOSTICS
Upon successful completion, a value of 0 is returned.
Otherwise, a value of \-1 is returned and
\f4errno\fP
is set to indicate the error.
.\"	@(#)kill.2	6.2 of 9/6/83
.Ee
