The kill function sends a signal (sig) to a process or group of processes (pid). If sig is 0 (null signal), only error checking (such as to check the validity of pid) is performed. No signal is sent. If the real or effective user ID of the sending process does not match the real or saved set-user-ID of the receiving process (pid), the kill function will fail with errno set to EPERM. For pid > 0, sig is sent to process ID pid. For pid == 0, sig is sent to all processes (except an unspecified set of system processes) where process group ID == process group ID of sender. The sending process must also have permission to send a signal to the receiving process. For pid == -1, sig is sent to all processes (except an unspecified set of system processes). The sending process must have permission to send signal sig to the receiving process. For pid below 0 and != -1, sig is sent to all processes (except an unspecified set of system processes) where process group ID == absolute value of pid. The sending process must have permission to send signal sig to the receiving process. If it turns out that sig should be sent to the sending process (based on pid's value), then it (or at least one pending unblocked signal) will be sent to the sending thread before the kill() returns. However, if one of these is the case: - sig is blocked for the calling thread - another thread has sign unblocked - another thread is waiting in a sigwait() function for sig it will not be sent. If SIGCONT is being sent to a process that happens to be a member of the same session as the sending process, then the user ID tests described in assertion 3 won't be applied. It is allowed for an implementation to impose further restrictions on the sending of signals (for extended security controls), including restrictions on the null signal. A particular example is to deny the existence of some or all of the processes specified by the pid parameter. If the process has permission to sent sig to at least one of the processes specified by pid, then kill() is successful. When kill() is successful, it returns 0. When kill() is not successful, it returns -1 and sets errno to indicate the type of error. The kill() function sets errno to EINVAL if the value of the sig argument is an invalid or unsupported signal number. The kill() function sets errno to EPERM if the process does not have permission to send the signal to at least one receiving process. The kill() function sets errno to ESRCH if not one process or process group can be found corresponding to the pid parameter.