kill() - send signal to a process
#include <signal.h>
int kill (pid_t pid, int sig)
The kill(2) function sends the signal given by sig to pid, a process or a group of processes. Sig may be one of the signals specified for sigaction(2) or it may be 0. If sig is 0, error checking is performed but no signal is actually sent. (This can be used to check the validity of pid.)
For a process to have permission to send a signal to the process pid, the real or effective user ID of the receiving process must match the real or effective user ID of the sending process or the user must have appropriate privileges. These user ID tests are not applied when sending SIGCONT to a process that is a member of the same session as the sending process.
The kill(2) function only delivers signals to processes in the Interix subsystem (that is, POSIX processes), not to Win32 processes. If you attempt to kill(2) a process which has exec(2)ed a Win32 process, the signal isn't delivered to the Win32 process.
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.
The kill(2) call will fail and no signal will be sent if:
To use the kill(2) function to send a signal to a process that does not have the same real/effective UID as the calling process, the calling process must have one of these Windows privileges:
$ kill 1
to cause the Interix subsystem to re-read updated values in the
registry without rebooting.Only one is required to send a signal to a process with a different real/effective UID than the calling process, but SE_SECURITY_NAME does confer additional privileges.
getpid(2)
getpgrp(2)
sigaction(2)
privileges(5)