OSDN Git Service

0909bc2b5f49860be249eababc73fe4f5928057e
[linuxjm/LDP_man-pages.git] / draft / man2 / kill.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
4 .\"
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.
8 .\"
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.
13 .\"
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
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\"
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
38 .\"     sends a signal.
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
43 .\"
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
55 .\"
56 .\"WORD:        signal                  シグナル
57 .\"WORD:        process group           プロセス・グループ
58 .\"WORD:        permission              許可
59 .\"WORD:        privileges              特権
60 .\"WORD:        set-user-id             セットユーザーID
61 .\"WORD:        signal handler          シグナルハンドラー
62 .\"
63 .TH KILL 2 2009-09-15 "Linux" "Linux Programmer's Manual"
64 .\"O .SH NAME
65 .SH 名前
66 .\"O kill \- send signal to a process
67 kill \- プロセスにシグナルを送る
68 .\"O .SH SYNOPSIS
69 .SH 書式
70 .nf
71 .B #include <sys/types.h>
72 .br
73 .B #include <signal.h>
74 .sp
75 .BI "int kill(pid_t " pid ", int " sig );
76 .fi
77 .sp
78 .in -4n
79 .\"O Feature Test Macro Requirements for glibc (see
80 .\"O .BR feature_test_macros (7)):
81 glibc 向けの機能検査マクロの要件
82 .RB ( feature_test_macros (7)
83 参照):
84 .in
85 .sp
86 .ad l
87 .BR kill ():
88 _POSIX_C_SOURCE\ >=\ 1 || _XOPEN_SOURCE || _POSIX_SOURCE
89 .ad b
90 .\"O .SH DESCRIPTION
91 .SH 説明
92 .\"O The
93 .\"O .BR kill ()
94 .\"O system call
95 .\"O can be used to send any signal to any process group or process.
96 システムコールの
97 .BR kill ()
98 は、任意のプロセス・グループもしくはプロセスにシグナルを
99 送るのに使われる。
100 .PP
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 を持つプロセスに送られる。
105 .PP
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 で指定したシグナルが送られる。
111 .PP
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) へはシグナルは送られない。
118 以下の関連部分も参照のこと。
119 .PP
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 で指定したシグナルが送られる。
125 .PP
126 .\"O If \fIsig\fP is 0, then no signal is sent, but error checking is still
127 .\"O performed;
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 の存在確認を行うことができる。
133
134 .\"O For a process to have permission to send a signal
135 .\"O it must either be privileged (under Linux: have the
136 .\"O .B CAP_KILL
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.
140 .\"O In the case of
141 .\"O .B SIGCONT
142 .\"O it suffices when the sending and receiving
143 .\"O processes belong to the same session.
144 あるプロセスがシグナルを送る許可を持つには、
145 そのプロセスが特権 (Linux では
146 .B CAP_KILL
147 ケーパビリティ) を持つプロセスであるか、シグナルを送る側のプロセスの
148 実UID か実効UID が受ける側のプロセスの実 set-UID か
149 保存 (saved) set-UID が一致していなければならない。
150 .B SIGCONT
151 の場合は、シグナルを送信するプロセスと受信するプロセスが
152 同じセッションに所属していれば十分である。
153 .\"O .SH "RETURN VALUE"
154 .SH 返り値
155 .\"O On success (at least one signal was sent), zero is returned.
156 .\"O On error, \-1 is returned, and
157 .\"O .I errno
158 .\"O is set appropriately.
159 成功した場合 (少なくとも一つのシグナルが送信された場合)、
160 0 が返される。エラーの場合 \-1 が返され、
161 .I errno
162 が適切に設定される。
163 .\"O .SH ERRORS
164 .SH エラー
165 .TP
166 .B EINVAL
167 .\"O An invalid signal was specified.
168 無効なシグナルを指定した。
169 .TP
170 .B EPERM
171 .\"O The process does not have permission to send the signal
172 .\"O to any of the receiving processes.
173 プロセスが、受信するプロセスのいずれに対しても
174 シグナルを送る許可を持っていない。
175 .TP
176 .B ESRCH
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
181 .\"O .BR wait (2)ed
182 .\"O for.
183 指定したプロセスまたはプロセス・グループが存在しなかった。
184 ゾンビプロセスは存在するプロセスとしてみなされる。
185 ゾンビプロセスとはすでに処理は終了しているが、親プロセスによる
186 .BR wait ()
187 処理が行われていないプロセスのことである。
188 .\"O .SH "CONFORMING TO"
189 .SH 準拠
190 SVr4, 4.3BSD, POSIX.1-2001.
191 .\"O .SH NOTES
192 .SH 注意
193 .\"O The only signals that can be sent to process ID 1, the
194 .\"O .I init
195 .\"O process, are those for which
196 .\"O .I init
197 .\"O has explicitly installed signal handlers.
198 .\"O This is done to assure the
199 .\"O system is not brought down accidentally.
200 プロセス番号 1 の
201 .I init
202 プロセスに送ることができるシグナルは、
203 .I init
204 が明示的にシグナルハンドラを設定したシグナルだけである。
205 こうなっているのは、誤ってシステムをダウンさせないようにするためである。
206 .LP
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 但し、システム実装時に定められたシステムプロセスは
216 シグナルの送信対象から除外される。
217 Linux では、プロセスが自分自身にシグナルを送れるようになっているが、
218 Linux の \fIkill(\-1,sig)\fP は呼び出し元のプロセスにはシグナルを送らない。
219 .LP
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),
225 .\"O at least one
226 .\"O unblocked signal must be delivered to the sending thread before the
227 .\"O .BR kill ()
228 .\"O returns.
229 POSIX.1-2001 では以下の動作になることを要求している。
230 自分自身にシグナルを送ると、シグナルを送ったスレッドがそのシグナルをブロック
231 しておらず、他のどのスレッドもそのシグナルを受ける状態にもなく
232 .BR sigwait (3)
233 でそのシグナルを待ってもいない場合、
234 .BR kill ()
235 が返る前に少なくとも一つのブロックされていない
236 シグナルがシグナルを送ったスレッドに配送されなければならない。
237 .\"O .SS "Linux Notes"
238 .SS "Linux での注意"
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 以降で
260 適用されている。
261 .\"O .SH BUGS
262 .SH バグ
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,
265 .\"O .BR kill ()
266 .\"O failed with the error
267 .\"O .B EPERM
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 に対してのみシグナルを送る許可を持っている場合に、
276 .BR kill ()
277 がエラー
278 .B EPERM
279 で失敗するというバグがある。
280 このエラーが返るにもかかわらず、そのシグナルは呼び出し元が
281 シグナルを送る許可を持つ全てのプロセスへ送られる。
282 .\"O .SH "SEE ALSO"
283 .SH 関連項目
284 .BR _exit (2),
285 .BR killpg (2),
286 .BR signal (2),
287 .BR tkill (2),
288 .BR exit (3),
289 .BR sigqueue (3),
290 .BR credentials (7),
291 .BR capabilities (7),
292 .BR signal (7)