KILL(2) SysV 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 (pid, sig)
pid_t pid;
int sig;
DESCRIPTION
kill sends a signal to the process or group of processes specified by
pid. The signal to be sent is specified by sig, and is either 0 or some
other value described in signal(2). If sig is 0 (the null signal), kill
performs error checking but does not send a signal. This can be used to
check the validity of pid.
The real or effective user ID of the sending process must match the real
or effective user ID of the receiving process, unless the effective user
ID of the sending process is super-user.
The processes with a process ID of 0 and a process ID of 1 are special
processes (see intro(2)) and will be referred to below as proc0 and
proc1, respectively.
The behavior of kill depends upon the value of pid:
+ If pid is greater than 0, sig will be sent to the process whose
process ID is equal to pid. pid may equal 1.
+ If pid 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.
+ If pid is -1 and the effective user ID of the sender is not super-
user, 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 is -1 and the effective user ID of the sender is super-user,
sig will be sent to all processes (excluding proc0 and proc1).
+ If pid is negative but not -1, sig will be sent to all processes whose
process group ID is equal to the absolute value of pid.
If pid is -1, the sending process is sent the signal along with all
other processes for which the sending process has permission to send
the signal. Prior to SR10.4, the sending process was not sent the
signal.
NOTE
No process under Domain/OS SysV has an ID of 0.
ERRORS
kill will fail and no signal will be sent if one or more of the following
are true:
[EINVAL] sig is not a valid signal number.
[EINVAL] sig is SIGKILL and pid is 1 (proc1).
[ESRCH] No process can be found corresponding to that specified by pid.
[EPERM] The user ID of the sending process is not super-user, and its
real or effective user ID does not match the real or effective
user ID of the receiving process.
SEE ALSO
getpid(2), setpgrp(2), signal(2), sigset(2).
kill(1) in the SysV Command Reference.
DIAGNOSTICS
A successful call returns 0. A failed call returns -1 and sets errno as
indicated under "Errors."