NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | USAGE | ATTRIBUTES | SUMMARY OF TRUSTED SOLARIS CHANGES | SEE ALSO
#include <sys/types.h> #include <signal.h>int kill(pid_t pid, int sig);
kill() sends a signal to a process or a group of processes specified by pid. The signal that is to be sent, specified by sig, is either one from the list given in signal() (see signal(3HEAD)), or 0. If sig is 0 (the null signal), error checking is performed but no signal is actually sent. This method can be used to check the validity of pid.
The sending process must have MAC write access to the receiving processes. 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 sending process has the PRIV_PROC_OWNER
effective privilege, or sig is SIGCONT
and the sending process has the same session ID as the receiving process.
If pid is greater than 0, sig will be sent to the process whose process ID is equal to pid.
If pid is negative but not (pid_t)-1, sig will be sent to all 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 pid is 0, sig will be sent to all processes excluding special processes (see intro(2)) whose process group ID is equal to the process group ID of the sender.
If pid is (pid_t)-1 and the sender does not have PRIV_PROC_OWNER
in its effective privilege set, sig will be sent to all processes excluding special processes whose real user ID is equal to the effective user ID of the sender.
kill() returns:
On success.
On failure, does not send a signal, and sets errno to indicate the error.
The kill() function will fail if:
The sig argument is not a valid signal number.
The calling process failed in MAC write access to the receiving process and does not have PRIV_PROC_MAC_WRITE
overriding privilege.
sig is SIGKILL
and pid is (pid_t)1. (That is, the calling process does not have permission to send the signal to any of the processes specified by pid).
The effective user of the calling process does not match the real or saved user and the sending process does not have PRIV_PROC_OWNER privilege
, and the calling process is not sending SIGCONT
to a process that shares
the same session ID.
No process or process group can be found corresponding to that specified by pid.
The sigsend(2) function provides a more versatile way to send signals to processes.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
MT-Level | Async-Signal-Safe |
Process MAC write policy and the process owner policy is checked.
NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | USAGE | ATTRIBUTES | SUMMARY OF TRUSTED SOLARIS CHANGES | SEE ALSO