The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

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 will send a signal to a process or a group of processes specified by pid. The signal to be sent is specified by sig and is either one from the list given in <signal.h> or 0. If sig is 0 (the null signal), error checking is performed but no signal is actually sent. The null signal can be used to check the validity of pid.

{_POSIX_SAVED_IDS} will be defined on all XSI-conformant systems, and for a process to have permission to send a signal to a process designated by pid, the real or effective user ID of the sending process must match the real or saved set-user-ID of the receiving process, unless the sending process has appropriate privileges.

If pid is greater than 0, sig will be sent to the process whose process ID is equal to pid.

If pid is 0, sig will be sent to all processes (excluding an unspecified set of system processes) whose process group ID is equal to the process group ID of the sender, and for which the process has permission to send a signal.

If pid is -1, sig will be sent to all processes (excluding an unspecified set of system processes) for which the process has permission to send that signal.

If pid is negative, but not -1, sig will be sent to all processes (excluding an unspecified set of system processes) whose process group ID is equal to the absolute value of pid, and for which the process has permission to send a signal.

If the value of pid causes sig to be generated for the sending process, and if sig is not blocked for the calling thread and if no other thread has sig unblocked or is waiting in a sigwait() function for sig, either sig or at least one pending unblocked signal will be delivered to the sending thread before kill() returns.

The user ID tests described above will not be applied when sending SIGCONT to a process that is a member of the same session as the sending process.

An implementation that provides extended security controls may impose further implementation-dependent restrictions on the sending of signals, including the null signal. In particular, the system may deny the existence of some or all of the processes specified by pid.

The kill() function is successful if the process has permission to send sig to any of the processes specified by pid. If kill() fails, no signal will be sent.

 RETURN VALUE

Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error.

 ERRORS

The kill() function will fail if:
[EINVAL]
The value of the sig argument is an invalid or unsupported signal number.
[EPERM]
The process does not have permission to send the signal to any receiving process.
[ESRCH]
No process or process group can be found corresponding to that specified by pid.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

getpid(), raise(), setsid(), sigaction(), <signal.h>, sigqueue(), <sys/types.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group