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

DESCRIPTION

15       The  kill()  system  call can be used to send any signal to any process
16       group or process.
17
18       If pid is positive, then signal sig is sent to pid.
19
20       If pid equals 0, then sig is sent to every process in the process group
21       of the current process.
22
23       If pid equals -1, then sig is sent to every process for which the call‐
24       ing process has permission  to  send  signals,  except  for  process  1
25       (init), but see below.
26
27       If  pid  is  less  than  -1,  then  sig is sent to every process in the
28       process group -pid.
29
30       If sig is 0, then no signal is sent, but error checking is  still  per‐
31       formed.
32
33       For  a  process  to  have permission to send a signal it must either be
34       privileged (under Linux: have the CAP_KILL capability), or the real  or
35       effective  user  ID of the sending process must equal the real or saved
36       set-user-ID of the target process.  In the case of SIGCONT it  suffices
37       when the sending and receiving processes belong to the same session.
38

RETURN VALUE

40       On success (at least one signal was sent), zero is returned.  On error,
41       -1 is returned, and errno is set appropriately.
42

ERRORS

44       EINVAL An invalid signal was specified.
45
46       EPERM  The process does not have permission to send the signal  to  any
47              of the target processes.
48
49       ESRCH  The  pid or process group does not exist.  Note that an existing
50              process might be a zombie, a  process  which  already  committed
51              termination, but has not yet been wait()ed for.
52

NOTES

54       The  only  signals that can be sent process ID 1, the init process, are
55       those for which init has explicitly installed signal handlers.  This is
56       done to assure the system is not brought down accidentally.
57
58       POSIX.1-2001  requires that kill(-1,sig) send sig to all processes that
59       the current process may send  signals  to,  except  possibly  for  some
60       implementation-defined  system  processes.   Linux  allows a process to
61       signal itself, but on Linux the call kill(-1,sig) does not  signal  the
62       current process.
63
64       POSIX.1-2001  requires  that if a process sends a signal to itself, and
65       the sending thread does not have  the  signal  blocked,  and  no  other
66       thread has it unblocked or is waiting for it in sigwait(), at least one
67       unblocked signal must be delivered to the  sending  thread  before  the
68       kill().
69

BUGS

71       In  2.6  kernels  up to and including 2.6.7, there was a bug that meant
72       that when sending signals to a process group, kill()  failed  with  the
73       error EPERM if the caller did have permission to send the signal to any
74       (rather than all) of the members of the process group.  Notwithstanding
75       this  error  return,  the signal was still delivered to all of the pro‐
76       cesses for which the caller had permission to signal.
77

LINUX HISTORY

79       Across different kernel versions, Linux has  enforced  different  rules
80       for the permissions required for an unprivileged process to send a sig‐
81       nal to another process.  In kernels 1.0 to 1.2.2,  a  signal  could  be
82       sent  if  the  effective  user  ID  of  the  sender matched that of the
83       receiver, or the real user  ID  of  the  sender  matched  that  of  the
84       receiver.   From  kernel  1.2.3 until 1.3.77, a signal could be sent if
85       the effective user ID of the sender matched either the real  or  effec‐
86       tive  user  ID  of  the  receiver.  The current rules, which conform to
87       POSIX.1-2001, were adopted in kernel 1.3.78.
88

CONFORMING TO

90       SVr4, 4.3BSD, POSIX.1-2001
91

SEE ALSO

93       _exit(2), killpg(2), signal(2), sigqueue(2), tkill(2),  exit(3),  capa‐
94       bilities(7), signal(7)
95
96
97
98Linux 2.6.7                       2004-06-24                           KILL(2)
Impressum