kill(2)
NAME
kill − send signal to a process
SYNTAX
kill(pid, sig)
int pid, sig;
DESCRIPTION
The kill system call sends the signal sig to a process, specified by the process number pid. The sig may be one of the signals specified in sigvec(,), or it may be 0, in which case error checking is performed but no signal is actually sent. This can be used to check the validity of pid.
The sending and receiving processes must have the same effective user ID, otherwise this call is restricted to the superuser. An exception is the signal SIGCONT, which may always be sent to any child or grandchild of the current process.
If the process number is 0, the signal is sent to all other processes in the sender’s process group. This is a variant of killpg(.).
If the process number is −1, and the user is the superuser, the signal is broadcast except to system processes and the process sending the signal.
Processes may send signals to themselves.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.
ENVIRONMENT
Differs from the System V version when pid = −1 and the effective user ID of the sender is not the superuser. In this case sig should be, but is not, sent to all processes, excluding special system process, whose real user ID is equal to the effective user ID of the sender.
When your program is compiled using the System V environment and the pid is negative but not −1, the sig will be sent to all processes whose process-group-id is equal to the absolute value of pid.
DIAGNOSTICS
The kill system call will fail and no signal will be sent if any of the following occur:
[EINVAL]
The sig is not a valid signal number.
[ESRCH]
No process can be found corresponding to that specified by pid.
[EPERM]
The sending process is not the superuser and its effective user id does not match the effective user ID of the receiving process.