1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified by Thomas Koenig <ig25@rz.uni-karlsruhe.de>
27 .\" Modified 1993-07-23 by Rik Faith <faith@cs.unc.edu>
28 .\" Modified 1993-07-25 by Rik Faith <faith@cs.unc.edu>
29 .\" Modified 1995-11-01 by Michael Haardt
30 .\" <michael@cantor.informatik.rwth-aachen.de>
31 .\" Modified 1996-04-14 by Andries Brouwer <aeb@cwi.nl>
32 .\" [added some polishing contributed by Mike Battersby <mib@deakin.edu.au>]
33 .\" Modified 1996-07-21 by Andries Brouwer <aeb@cwi.nl>
34 .\" Modified 1997-01-17 by Andries Brouwer <aeb@cwi.nl>
35 .\" Modified 2001-12-18 by Andries Brouwer <aeb@cwi.nl>
36 .\" Modified 2002-07-24 by Michael Kerrisk <mtk.manpages@gmail.com>
37 .\" Added note on historical rules enforced when an unprivileged process
39 .\" Modified 2004-06-16 by Michael Kerrisk <mtk.manpages@gmail.com>
40 .\" Added note on CAP_KILL
41 .\" Modified 2004-06-24 by aeb
42 .\" Modified, 2004-11-30, after idea from emmanuel.colbus@ensimag.imag.fr
44 .\" Japanese Version Copyright (c) 1997 Kazuyuki Tanisako
45 .\" all rights reserved.
46 .\" Translated 1997-05-17, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
47 .\" Modified 1997-05-27, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
48 .\" Modified 1998-02-05, Kazuyuki Tanisako <tanisako@osa.dec-j.co.jp>
49 .\" Updated 2001-12-27, Kentaro Shirakata <argrath@ub32.org>
50 .\" Updated 2002-01-03, Kentaro Shirakata <argrath@ub32.org>
51 .\" Updated 2002-09-27, Kentaro Shirakata <argrath@ub32.org>
52 .\" Updated 2005-02-27, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
53 .\" Updated 2005-12-05, Akihiro MOTOKI, Catch up to LDP man-pages 2.16
54 .\" Updated 2008-08-06, Akihiro MOTOKI, LDP v3.05
57 .\"WORD: process group プロセス・グループ
58 .\"WORD: permission 許可
59 .\"WORD: privileges 特権
60 .\"WORD: set-user-id セットユーザーID
61 .\"WORD: signal handler シグナルハンドラー
63 .TH KILL 2 2009-09-15 "Linux" "Linux Programmer's Manual"
66 .\"O kill \- send signal to a process
71 .B #include <sys/types.h>
73 .B #include <signal.h>
75 .BI "int kill(pid_t " pid ", int " sig );
79 .\"O Feature Test Macro Requirements for glibc (see
80 .\"O .BR feature_test_macros (7)):
82 .RB ( feature_test_macros (7)
88 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
95 .\"O can be used to send any signal to any process group or process.
98 は、任意のプロセス・グループもしくはプロセスにシグナルを
101 .\"O If \fIpid\fP is positive, then signal \fIsig\fP is sent to the
102 .\"O process with the ID specified by \fIpid\fP.
103 \fIpid\fP に正の値を指定した場合、シグナル \fIsig\fP が
104 \fIpid\fP で指定された ID を持つプロセスに送られる。
106 .\"O If \fIpid\fP equals 0, then \fIsig\fP is sent to every process in the
107 .\"O process group of the calling process.
108 \fIpid\fP に 0 を指定した場合、
109 呼び出し元のプロセスのプロセス・グループに属するすべてのプロセスに
110 \fIsig\fP で指定したシグナルが送られる。
112 .\"O If \fIpid\fP equals \-1, then \fIsig\fP is sent to every process
113 .\"O for which the calling process has permission to send signals,
114 .\"O except for process 1 (\fIinit\fP), but see below.
115 \fIpid\fP に \-1 を指定した場合、 \fIsig\fP で指定したシグナルが、
116 呼び出し元のプロセスがシグナルを送る許可を持つ全てのプロセスに
117 送られる。但し、プロセス番号 1 (\fIinit\fP) へはシグナルは送られない。
120 .\"O If \fIpid\fP is less than \-1, then \fIsig\fP is sent to every process
121 .\"O in the process group whose ID is \fI\-pid\fP.
122 \fIpid\fP に \-1 より小さな値を指定した場合、
123 ID が \fI\-pid\fP のプロセス・グループに属するすべてのプロセスに
124 \fIsig\fP で指定したシグナルが送られる。
126 .\"O If \fIsig\fP is 0, then no signal is sent, but error checking is still
128 .\"O this can be used to check for the existence of a process ID or
129 .\"O process group ID.
130 \fIsig\fP に 0 を指定した場合、シグナルは送られないが、
131 エラーのチェックは行われる。これを使って、プロセス ID や
132 プロセスグループ ID の存在確認を行うことができる。
134 .\"O For a process to have permission to send a signal
135 .\"O it must either be privileged (under Linux: have the
137 .\"O capability), or the real or effective
138 .\"O user ID of the sending process must equal the real or
139 .\"O saved set-user-ID of the target process.
142 .\"O it suffices when the sending and receiving
143 .\"O processes belong to the same session.
144 あるプロセスがシグナルを送る許可を持つには、
147 ケーパビリティ) を持つプロセスであるか、シグナルを送る側のプロセスの
148 実UID か実効UID が受ける側のプロセスの実 set-UID か
149 保存 (saved) set-UID が一致していなければならない。
151 の場合は、シグナルを送信するプロセスと受信するプロセスが
152 同じセッションに所属していれば十分である。
153 .\"O .SH "RETURN VALUE"
155 .\"O On success (at least one signal was sent), zero is returned.
156 .\"O On error, \-1 is returned, and
158 .\"O is set appropriately.
159 成功した場合 (少なくとも一つのシグナルが送信された場合)、
160 0 が返される。エラーの場合 \-1 が返され、
167 .\"O An invalid signal was specified.
171 .\"O The process does not have permission to send the signal
172 .\"O to any of the receiving processes.
173 プロセスが、受信するプロセスのいずれに対しても
177 .\"O The pid or process group does not exist.
178 .\"O Note that an existing process might be a zombie,
179 .\"O a process which already committed termination, but
180 .\"O has not yet been
183 指定したプロセスまたはプロセス・グループが存在しなかった。
184 ゾンビプロセスは存在するプロセスとしてみなされる。
185 ゾンビプロセスとはすでに処理は終了しているが、親プロセスによる
187 処理が行われていないプロセスのことである。
188 .\"O .SH "CONFORMING TO"
190 SVr4, 4.3BSD, POSIX.1-2001.
193 .\"O The only signals that can be sent to process ID 1, the
195 .\"O process, are those for which
197 .\"O has explicitly installed signal handlers.
198 .\"O This is done to assure the
199 .\"O system is not brought down accidentally.
204 が明示的にシグナルハンドラを設定したシグナルだけである。
205 こうなっているのは、誤ってシステムをダウンさせないようにするためである。
207 .\"O POSIX.1-2001 requires that \fIkill(\-1,sig)\fP send \fIsig\fP
208 .\"O to all processes that the calling process may send signals to,
209 .\"O except possibly for some implementation-defined system processes.
210 .\"O Linux allows a process to signal itself, but on Linux the call
211 .\"O \fIkill(\-1,sig)\fP does not signal the calling process.
212 POSIX.1-2001 では、 \fIkill(\-1,sig)\fP が
213 呼び出し元のプロセスがシグナルを送ることが出来るプロセス全てに
214 \fIsig\fP を送ることを要求している。
215 但し、システム実装時に定められたシステムプロセスは
217 Linux では、プロセスが自分自身にシグナルを送れるようになっているが、
218 Linux の \fIkill(\-1,sig)\fP は呼び出し元のプロセスにはシグナルを送らない。
220 .\"O POSIX.1-2001 requires that if a process sends a signal to itself,
221 .\"O and the sending thread does not have the signal blocked,
222 .\"O and no other thread
223 .\"O has it unblocked or is waiting for it in
224 .\"O .BR sigwait (3),
226 .\"O unblocked signal must be delivered to the sending thread before the
229 POSIX.1-2001 では以下の動作になることを要求している。
230 自分自身にシグナルを送ると、シグナルを送ったスレッドがそのシグナルをブロック
231 しておらず、他のどのスレッドもそのシグナルを受ける状態にもなく
235 が返る前に少なくとも一つのブロックされていない
236 シグナルがシグナルを送ったスレッドに配送されなければならない。
237 .\"O .SS "Linux Notes"
239 .\"O Across different kernel versions, Linux has enforced different rules
240 .\"O for the permissions required for an unprivileged process
241 .\"O to send a signal to another process.
242 .\"O .\" In the 0.* kernels things chopped and changed quite
243 .\"O .\" a bit - MTK, 24 Jul 02
244 .\"O In kernels 1.0 to 1.2.2, a signal could be sent if the
245 .\"O effective user ID of the sender matched that of the receiver,
246 .\"O or the real user ID of the sender matched that of the receiver.
247 .\"O From kernel 1.2.3 until 1.3.77, a signal could be sent if the
248 .\"O effective user ID of the sender matched either the real or effective
249 .\"O user ID of the receiver.
250 .\"O The current rules, which conform to POSIX.1-2001, were adopted
251 .\"O in kernel 1.3.78.
252 Linux では、特権のないプロセスが他のプロセスにシグナルを送信するために
253 必要な権限についてのルールが、カーネルバージョンにより違っている。
254 .\" 0.* カーネルの話は割愛し、多少変更した。- MTK, 24 Jul 02
255 カーネル 1.0 から 1.2.2 では、送信側の実効ユーザーID が受信側の
256 実効ユーザー IDと一致すればシグナルを送信できた。
257 カーネル 1.2.3 から 1.3.77では、送信側の実効ユーザーID が受信側の
258 実ユーザーID か実効ユーザーID のいずれかと一致すればシグナルを送信できた。
259 現在のルールは、POSIX.1-2001 に準拠しており、カーネル 1.3.78 以降で
263 .\"O In 2.6 kernels up to and including 2.6.7,
264 .\"O there was a bug that meant that when sending signals to a process group,
266 .\"O failed with the error
268 .\"O if the caller did have permission to send the signal to \fIany\fP (rather
269 .\"O than \fIall\fP) of the members of the process group.
270 .\"O Notwithstanding this error return, the signal was still delivered
271 .\"O to all of the processes for which the caller had permission to signal.
272 バージョン 2.6.7 以前の 2.6 系のカーネルには、
273 プロセスグループにシグナルを送ったときに、
274 呼び出し元のプロセスがプロセスグループの (全メンバーではなく) 一部のメンバー
275 に対してのみシグナルを送る許可を持っている場合に、
280 このエラーが返るにもかかわらず、そのシグナルは呼び出し元が
281 シグナルを送る許可を持つ全てのプロセスへ送られる。
291 .BR capabilities (7),