[Previous]
[Contents]
[Next]

kill()

send a signal to a process or a group of processes

Synopsis:

#include <sys/types.h>
#include <signal.h>

int kill( pid_t pid, int sig );

Description:

The kill() function sends the signal sig to a process or group of processes specified by pid. If sig is zero, then no signal is sent, but the validity of pid is still checked.

For a process to have permission to send a signal to a process, the real or effective user ID of the sending process must match the real or effective user ID of the receiving process.

If pid is greater than zero, then sig is sent to the single process that has that process ID.

If pid is equal to zero, then sig is sent to all processes that are in the same process group as the sending process.

If pid is less than zero, sig is sent to every process that is a member of the process group -pid.

If the value of pid causes sig to be generated for the sending process, and if sig is not blocked, either sig or at least one pending unblocked signal is delivered before the kill function returns.

Returns:

Upon successful completion, the kill() function returns a value of zero. If an error occurs, -1 is returned, and errno is set.

Errors:

EINVAL
sig is invalid.
EPERM
The process does not have permission to send this signal to any receiving process.
ESRCH
pid does not exist.

Examples:

See sigprocmask().

Classification:

POSIX 1003.1

Safety:
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

getpid(), setsid(), sigaction(), signal()


[Previous]
[Contents]
[Next]