OSDN Git Service

info/GNU_which: Add some explanations.
[linuxjm/jm.git] / manual / glibc-linuxthreads / draft / man3 / pthread_sigmask.3
1 .\"   Copyright (C) 1996-1999 Free Software Foundation, Inc.
2 .\"
3 .\"   Permission is granted to make and distribute verbatim copies of
4 .\" this manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\"   Permission is granted to copy and distribute modified versions of
8 .\" this manual under the conditions for verbatim copying, provided that
9 .\" the entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\"   Permission is granted to copy and distribute translations of this
13 .\" manual into another language, under the above conditions for modified
14 .\" versions, except that this permission notice may be stated in a
15 .\" translation approved by the Foundation.
16 .\"
17 .\" Copyright (C) 1996 Xavier Leroy.
18 .\"
19 .\" Japanese Version Copyright (C) 2002-2003 Suzuki Takashi
20 .\"         all rights reserved.
21 .\" Translated Tue Dec 31 20:02:27 JST 2002
22 .\"         by Suzuki Takashi.
23 .\"
24 .\"WORD:    handling of signals シグナルハンドリング
25 .\"WORD:    signal mask         シグナルマスク
26 .\"WORD:    calling thread      呼び出しスレッド
27 .\"WORD:    signal action       シグナルアクション
28 .\"WORD:    signal handler      シグナルハンドラ
29 .\"
30 .\"
31 .TH PTHREAD_SIGNAL 3 LinuxThreads
32
33
34 .\"O .SH NAME
35 .\"O pthread_sigmask, pthread_kill, sigwait \- handling of signals in threads
36 .SH "名前"
37 pthread_sigmask, pthread_kill, sigwait \- スレッド内でのシグナルハンドリング
38
39 .\"O .SH SYNOPSIS
40 .SH "書式"
41 .B #include <pthread.h>
42 .br
43 .B #include <signal.h>
44
45 .BI "int pthread_sigmask(int " how ", const sigset_t *" newmask ", sigset_t *" oldmask ");"
46
47 .BI "int pthread_kill(pthread_t " thread ", int " signo ");"
48
49 .BI "int sigwait(const sigset_t *" set ", int *" sig ");"
50
51 .\"O .SH DESCRIPTION
52 .SH "説明"
53
54 .\"O .B "pthread_sigmask"
55 .\"O changes the signal mask for the calling thread as
56 .\"O described by the 
57 .\"O .I "how"
58 .\"O and 
59 .\"O .I "newmask"
60 .\"O arguments. If 
61 .\"O .I "oldmask"
62 .\"O is not
63 .\"O .BR "NULL" ,
64 .\"O the previous signal mask is stored in the location pointed to
65 .\"O by 
66 .\"O .IR "oldmask" .
67 .B "pthread_sigmask"
68 は呼び出しスレッドのシグナルマスクを
69 引数
70 .I "how"
71 および
72 .I "newmask"
73 で指定されるように変更する。
74 .I "oldmask"
75
76 .B "NULL"
77 でないときには、直前のシグナルマスクが
78 .I "oldmask"
79 で指し示される領域に格納される。
80
81 .\"O The meaning of the 
82 .\"O .I "how"
83 .\"O and 
84 .\"O .I "newmask"
85 .\"O arguments is the same as for
86 .\"O .BR "sigprocmask" (2).
87 .\"O If 
88 .\"O .I "how"
89 .\"O is 
90 .\"O .BR "SIG_SETMASK" ,
91 .\"O the signal mask is set to
92 .\"O .IR "newmask" .
93 .\"O If 
94 .\"O .I "how"
95 .\"O is 
96 .\"O .BR "SIG_BLOCK" ,
97 .\"O the signals specified to 
98 .\"O .I "newmask"
99 .\"O are added to the current signal mask.  If 
100 .\"O .I "how"
101 .\"O is 
102 .\"O .BR "SIG_UNBLOCK" ,
103 .\"O the
104 .\"O signals specified to 
105 .\"O .I "newmask"
106 .\"O are removed from the current signal
107 .\"O mask.
108 引数
109 .I "how"
110 および
111 .I "newmask"
112 の意味は
113 .BR "sigprocmask" (2)
114 の引数の意味と同じである。
115 .I "how"
116
117 .B "SIG_SETMASK"
118 のときには、
119 シグナルマスクが
120 .I "newmask"
121 に設定される。
122 .I "how"
123
124 .B "SIG_BLOCK"
125 のときには、
126 .I "newmask"
127 で指定されるシグナルが現時点のシグナルマスクに追加される。
128 .I "how"
129
130 .BR "SIG_UNBLOCK"
131 のときには、
132 .I "newmask"
133 で指定されるシグナルが現時点のシグナルマスクから取り除かれる。
134
135 .\"O Recall that signal masks are set on a per-thread basis, but signal
136 .\"O actions and signal handlers, as set with 
137 .\"O .BR "sigaction" (2),
138 .\"O are shared
139 .\"O between all threads.
140 シグナルマスクはスレッドごとに設定されることを思い出してほしい。
141 しかし
142 .BR "sigaction" (2)
143 で設定される
144 シグナルアクションとシグナルハンドラは、
145 すべてのスレッドで共通である。
146
147 .\"O .B "pthread_kill"
148 .\"O send signal number 
149 .\"O .I "signo"
150 .\"O to the thread
151 .\"O .IR "thread" .
152 .\"O The signal is delivered and handled as described in
153 .\"O .BR "kill" (2).
154 .B "pthread_kill"
155 はシグナル番号
156 .I "signo"
157 のシグナルを
158 スレッド
159 .IR "thread"
160 に送信する。
161 シグナルは
162 .BR "kill" (2)
163 に書かれているように配送されハンドルされる。
164
165 .\"O .B "sigwait"
166 .\"O suspends the calling thread until one of the signals
167 .\"O in 
168 .\"O .I "set"
169 .\"O is delivered to the calling thread. It then stores the number
170 .\"O of the signal received in the location pointed to by 
171 .\"O .I "sig"
172 .\"O and
173 .\"O returns. The signals in 
174 .\"O .I "set"
175 .\"O must be blocked and not ignored on
176 .\"O entrance to 
177 .\"O .BR "sigwait" .
178 .\"O If the delivered signal has a signal handler
179 .\"O function attached, that function is 
180 .\"O .I "not"
181 .\"O called.
182 .B "sigwait"
183
184 .I "set"
185 で指定されるシグナルのうちいずれか 1 つが呼び出しスレッドに
186 配送されるまで呼び出しスレッドの実行を停止する。
187 そして受信したシグナルの数を
188 .I "sig"
189 で指し示される領域に格納して返る。
190 .I "set"
191 で指定されるシグナルは
192 .B "sigwait"
193 に入るときにブロックされていなければならず、無視されてはならない。
194 配送されたシグナルに対するシグナルハンドラが登録されていても、
195 ハンドラ関数は呼び出され
196 .I "ない"
197
198
199 .\"O .SH CANCELLATION
200 .SH "取り消し"
201
202 .\"O .B "sigwait"
203 .\"O is a cancellation point.
204 .B "sigwait"
205 は取り消しポイントである。
206
207 .\"O .SH "RETURN VALUE"
208 .SH "返り値"
209
210 .\"O On success, 0 is returned. On failure, a non-zero error code is returned.
211 成功すると、0 が返る。
212 失敗の場合、非 0 のエラーコードが返る。
213
214 .\"O .SH ERRORS
215 .SH "エラー"
216
217 .\"O The 
218 .\"O .B "pthread_sigmask"
219 .\"O function returns the following error codes
220 .\"O on error:
221 .\"O .RS
222 .\"O .TP
223 .\"O .B "EINVAL"
224 .\"O .I "how"
225 .\"O is not one of 
226 .\"O .BR "SIG_SETMASK" ,
227 .\"O .BR "SIG_BLOCK" ,
228 .\"O or 
229 .\"O .B "SIG_UNBLOCK"
230 関数
231 .B "pthread_sigmask"
232 はエラーのとき、次のようなエラーコードを返す:
233 .RS
234 .TP
235 .B "EINVAL"
236 .I "how"
237
238 .B "SIG_SETMASK"
239 および
240 .B "SIG_BLOCK"
241
242 .B "SIG_UNBLOCK"
243 のいずれでもない。
244
245 .\"O .TP
246 .\"O .B "EFAULT"
247 .\"O .I "newmask"
248 .\"O or 
249 .\"O .I "oldmask"
250 .\"O point to invalid addresses
251 .\"O .RE
252 .TP
253 .B "EFAULT"
254 .I "newmask"
255 または
256 .I "oldmask"
257 が無効なアドレスを指している。
258 .RE
259
260 .\"O The 
261 .\"O .B "pthread_kill"
262 .\"O function returns the following error codes
263 .\"O on error:
264 .\"O .RS
265 .\"O .TP
266 .\"O .B "EINVAL"
267 .\"O .I "signo"
268 .\"O is not a valid signal number
269 関数
270 .B "pthread_kill"
271 はエラーのとき、次のようなエラーコードを返す:
272 .RS
273 .TP
274 .B "EINVAL"
275 .I "signo"
276 は有効なシグナル番号でない。
277
278 .\"O .TP
279 .\"O .B "ESRCH"
280 .\"O the thread 
281 .\"O .I "thread"
282 .\"O does not exist (e.g. it has already terminated)
283 .\"O .RE
284 .TP
285 .B "ESRCH"
286 スレッド
287 .I "thread"
288 は存在しない (例えば、そのスレッドはすでに終了している) 。
289 .RE
290
291 .\"O The 
292 .\"O .B "sigwait"
293 .\"O function never returns an error.
294 関数
295 .B "sigwait"
296 がエラーを返すことはない。
297
298 .\"O .SH AUTHOR
299 .SH "著者"
300 Xavier Leroy <Xavier.Leroy@inria.fr>
301
302 .\"O .SH "SEE ALSO"
303 .SH "関連項目"
304 .BR "sigprocmask" (2),
305 .BR "kill" (2),
306 .BR "sigaction" (2),
307 .BR "sigsuspend" (2).
308
309 .\"O .SH NOTES
310 .SH "注意"
311
312 .\"O For 
313 .\"O .B "sigwait"
314 .\"O to work reliably, the signals being waited for must be
315 .\"O blocked in all threads, not only in the calling thread, since
316 .\"O otherwise the POSIX semantics for signal delivery do not guarantee
317 .\"O that it's the thread doing the 
318 .\"O .B "sigwait"
319 .\"O that will receive the signal.
320 .\"O The best way to achieve this is block those signals before any threads
321 .\"O are created, and never unblock them in the program other than by
322 .\"O calling 
323 .\"O .BR "sigwait" .
324 .B "sigwait"
325 が確実に機能するように、
326 配送を待つシグナルは、呼び出しスレッドだけでなく
327 すべてのスレッドでブロックされていなければならない。
328 そうでない場合、POSIX のシグナル配送機構は
329 シグナルを受信するスレッドが
330 .B "sigwait"
331 を呼び出しているスレッドとなることを保証しない。
332 これを実現する最もよい方法は、
333 どのスレッドを生成するよりも前にそれらのシグナルをブロックし、
334 プログラム中では
335 .B "sigwait"
336 を呼び出す以外、ブロックを解除しないことである。
337
338 .\"O .SH BUGS
339 .SH "バグ"
340
341 .\"O Signal handling in LinuxThreads departs significantly from the POSIX
342 .\"O standard. According to the standard, ``asynchronous'' (external)
343 .\"O signals are addressed to the whole process (the collection of all
344 .\"O threads), which then delivers them to one particular thread. The
345 .\"O thread that actually receives the signal is any thread that does
346 .\"O not currently block the signal.
347 LinuxThreads のシグナルハンドリングは POSIX 標準とは大きく異なっている。
348 POSIX 標準によると、「非同期の」 (外部の) シグナルは
349 プロセス全体 (すべてのスレッドの集まり) に対して発行され、
350 その後特定の 1 つのスレッドに配送される。
351 実際にシグナルを受信するスレッドは
352 その時点でシグナルをブロックしていないスレッドのいずれかとなる。
353
354 .\"O In LinuxThreads, each thread is actually a kernel process with its own
355 .\"O PID, so external signals are always directed to one particular thread.
356 .\"O If, for instance, another thread is blocked in 
357 .\"O .B "sigwait"
358 .\"O on that
359 .\"O signal, it will not be restarted.
360 LinuxThreads では、
361 それぞれのスレッドが実際には固有の PID をもつカーネルプロセスであるため、
362 外部のシグナルは特定の 1 つのスレッドに直接配送される。
363 例えば、もし別のスレッドが
364 .B "sigwait"
365 を使ってそのシグナルをブロックしても、
366 そのスレッドが再開されることはない。
367
368 .\"O The LinuxThreads implementation of 
369 .\"O .B "sigwait"
370 .\"O installs dummy signal
371 .\"O handlers for the signals in 
372 .\"O .I "set"
373 .\"O for the duration of the wait. Since
374 .\"O signal handlers are shared between all threads, other threads must not
375 .\"O attach their own signal handlers to these signals, or alternatively
376 .\"O they should all block these signals (which is recommended anyway --
377 .\"O see the Notes section).
378 .B "sigwait"
379 の LinuxThreads の実装では、
380 .B "sigwait"
381 は待ちの期間中、
382 .I "set"
383 に含まれるシグナルに対応するダミーのシグナルハンドラを登録する。
384 シグナルハンドラはすべてのスレッドで共通であるため、
385 他のスレッドはこれらのシグナルに対して独自のシグナルハンドラを登録してはならない。
386 あるいはその代わりに、すべてのスレッドが
387 これらのシグナルをブロックしなければならない
388 (このことはとにかく推奨されている -- 注意のセクションを参照のこと) 。