1kill(2)                          System Calls                          kill(2)
2
3
4

NAME

6       kill - send a signal to a process or a group of processes
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <signal.h>
11
12       int kill(pid_t pid, int sig);
13
14

DESCRIPTION

16       The  kill()  function  sends  a  signal to a process or a group of pro‐
17       cesses. The process or group of processes to which the signal is to  be
18       sent is specified by pid. The signal that is to be sent is specified by
19       sig and is  either  one  from  the  list  given  in  signal  (see  sig‐
20       nal.h(3HEAD)),  or  0. If sig is 0 (the null signal), error checking is
21       performed but no signal is actually sent. This can be used to check the
22       validity of pid.
23
24
25       The  real  or  effective  user ID of the sending process must match the
26       real or saved (from one of functions in the exec(2) family) user ID  of
27       the  receiving  process,  unless  the  privilege  {PRIV_PROC_OWNER}  is
28       asserted in the effective set of the sending process (see Intro(2)), or
29       sig  is  SIGCONT and the sending process has the same session ID as the
30       receiving process. A process needs the basic privilege  {PRIV_PROC_SES‐
31       SION}  to  send  signals  to a process with a different session ID. See
32       privileges(5).
33
34
35       If pid is greater than 0, sig will be sent to the process whose process
36       ID is equal to  pid.
37
38
39       If pid is negative but not (pid_t)−1, sig will be sent to all processes
40       whose process group ID is equal to the absolute value of  pid  and  for
41       which the process has permission to send a signal.
42
43
44       If  pid  is 0, sig will be sent to all processes excluding special pro‐
45       cesses (see Intro(2)) whose process group ID is equal  to  the  process
46       group ID of the sender.
47
48
49       If pid is (pid_t)−1 and the {PRIV_PROC_OWNER} privilege is not asserted
50       in the effective set of the sending process, sig will be  sent  to  all
51       processes  excluding  special  processes whose real user ID is equal to
52       the effective user ID of the sender.
53
54
55       If pid is (pid_t)−1 and the {PRIV_PROC_OWNER} privilege is asserted  in
56       the  effective set of the sending process, sig will be sent to all pro‐
57       cesses excluding special processes.
58

RETURN VALUES

60       Upon successful completion, 0 is returned. Otherwise, −1  is  returned,
61       no signal is sent, and errno is set to indicate the error.
62

ERRORS

64       The kill() function will fail if:
65
66       EINVAL    The sig argument is not a valid signal number.
67
68
69       EPERM     The sig argument is SIGKILL and the pid argument is (pid_t)-1
70                 (that is, the calling process does  not  have  permission  to
71                 send the signal to any of the processes specified by pid).
72
73                 The  effective user of the calling process does not match the
74                 real or saved user and the calling process does not have  the
75                 {PRIV_PROC_OWNER}  privilege  asserted  in the effective set,
76                 and the calling process either is not sending  SIGCONT  to  a
77                 process  that shares the same session ID or does not have the
78                 {PRIV_PROC_SESSION} privilege asserted and is trying to  send
79                 a signal to a process with a different session ID.
80
81
82       ESRCH     No  process  or  process  group can be found corresponding to
83                 that specified by pid.
84
85

USAGE

87       The sigsend(2) function provides a more versatile way to  send  signals
88       to processes.
89

ATTRIBUTES

91       See attributes(5) for descriptions of the following attributes:
92
93
94
95
96       ┌─────────────────────────────┬─────────────────────────────┐
97       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
98       ├─────────────────────────────┼─────────────────────────────┤
99       │Interface Stability          │Standard                     │
100       ├─────────────────────────────┼─────────────────────────────┤
101       │MT-Level                     │Async-Signal-Safe            │
102       └─────────────────────────────┴─────────────────────────────┘
103

SEE ALSO

105       kill(1),  Intro(2),  exec(2),  getpid(2), getsid(2), setpgrp(2), sigac‐
106       tion(2), sigsend(2), signal(3C), signal.h(3HEAD), attributes(5), privi‐
107       leges(5), standards(5)
108
109
110
111SunOS 5.11                        22 Mar 2004                          kill(2)
Impressum