1KILL(2)                    Linux Programmer's Manual                   KILL(2)
2
3
4

NAME

6       kill - send signal to a process
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <signal.h>
11
12       int kill(pid_t pid, int sig);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       kill(): _POSIX_C_SOURCE
17

DESCRIPTION

19       The  kill()  system  call can be used to send any signal to any process
20       group or process.
21
22       If pid is positive, then signal sig is sent to the process with the  ID
23       specified by pid.
24
25       If pid equals 0, then sig is sent to every process in the process group
26       of the calling process.
27
28       If pid equals -1, then sig is sent to every process for which the call‐
29       ing  process  has  permission  to  send  signals,  except for process 1
30       (init), but see below.
31
32       If pid is less than -1, then sig  is  sent  to  every  process  in  the
33       process group whose ID is -pid.
34
35       If  sig  is  0,  then  no  signal is sent, but existence and permission
36       checks are still performed; this can be used to check for the existence
37       of  a  process  ID  or process group ID that the caller is permitted to
38       signal.
39
40       For a process to have permission to send a signal, it  must  either  be
41       privileged (under Linux: have the CAP_KILL capability in the user name‐
42       space of the target process), or the real or effective user ID  of  the
43       sending  process must equal the real or saved set-user-ID of the target
44       process.  In the case of SIGCONT, it suffices when the sending and  re‐
45       ceiving processes belong to the same session.  (Historically, the rules
46       were different; see NOTES.)
47

RETURN VALUE

49       On success (at least one signal was sent), zero is returned.  On error,
50       -1 is returned, and errno is set appropriately.
51

ERRORS

53       EINVAL An invalid signal was specified.
54
55       EPERM  The  calling process does not have permission to send the signal
56              to any of the target processes.
57
58       ESRCH  The target process or process group does not exist.   Note  that
59              an existing process might be a zombie, a process that has termi‐
60              nated execution, but has not yet been wait(2)ed for.
61

CONFORMING TO

63       POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
64

NOTES

66       The only signals that can be sent to process ID 1,  the  init  process,
67       are  those  for  which  init  has explicitly installed signal handlers.
68       This is done to assure the system is not brought down accidentally.
69
70       POSIX.1 requires that kill(-1,sig) send sig to all processes  that  the
71       calling process may send signals to, except possibly for some implemen‐
72       tation-defined system processes.  Linux allows a process to signal  it‐
73       self,  but  on  Linux the call kill(-1,sig) does not signal the calling
74       process.
75