kill(2) kill(2)
NAME
kill - send a signal to a process or a group of processes
SYNOPSIS
#include <sys/types.h>
#include <signal.h>
int kill(pidt pid, int sig);
DESCRIPTION
kill() sends a signal to a process or a group of processes. The pro-
cess or group of processes to which the signal is to be sent is speci-
fied by pid. The signal that is to be sent is specified by sig and is
either one from the list given in signal.h [see signal(5)], or 0. If
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 pid.
On XSI-conform systems, POSIXSAVED is defined by the system. There-
fore the real or effective user ID of the sending process must match
the real or saved [from exec(2)] user ID of the receiving process
unless the effective user ID of the sending process is superuser, or
unless sig is SIGCONT and the sending process has the same session ID
as the receiving process.
The process with ID 0 and the process with ID 1 are special processes
and will be referred to below as proc0 and proc1, respectively.
If pid is greater than 0, sig will be sent to the process whose pro-
cess ID is equal to pid. pid may equal 1.
If pid is negative but not (pidt)-1, sig will be sent to all pro-
cesses whose process group ID is equal to the absolute value of pid
and for which the process has permission to send a signal.
If pid (pidt) is 0, sig will be sent to all processes excluding proc0
and proc1 whose process group ID is equal to the process group ID of
the sender. Permission is needed to send a signal to process groups.
If pid (pidt) is -1 and the effective user ID of the sender is not
superuser, sig will be sent to all processes excluding proc0 and proc1
whose real user ID is equal to the effective user ID of the sender.
If pid (pidt) is -1, and the effective user ID of the sender is
superuser, sig will be sent to all processes excluding proc0 and
proc1.
Page 1 Reliant UNIX 5.44 Printed 11/98
kill(2) kill(2)
ERRORS
The following error code descriptions are function-specific. You will
find a general description in introprm2(2) or in errno(5).
kill() will fail and no signal will be sent if one or more of the fol-
lowing apply:
EINVAL sig is not a valid signal number.
EINVAL sig is SIGKILL and pid is (pidt)1 (i.e., pid specifies
proc1).
ESRCH No process or process group can be found corresponding to
that specified by pid.
EPERM The user ID of the sending process is not privileged, and
its real or effective user ID does not match the real or
saved user ID of the receiving process, and the calling pro-
cess is not sending SIGCONT to a process that shares the
same session ID.
NOTES
sigsend() is a more versatile way to send signals to processes. The
user is encouraged to use sigsend() instead of kill().
RESULT
Upon successful completion, a value of 0 is returned. Otherwise, a
value of -1 is returned and errno is set to indicate the error.
SEE ALSO
kill(1), getpid(2), getsid(2), setpgrp(2), sigaction(2), signal(2),
sigsend(2), signal(5), types(5).
Page 2 Reliant UNIX 5.44 Printed 11/98