1 .\" Copyright (C) 1996-1999 Free Software Foundation, Inc.
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.
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.
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.
17 .\" Copyright (C) 1996 Xavier Leroy.
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.
24 .\"WORD: handling of signals シグナルハンドリング
25 .\"WORD: signal mask シグナルマスク
26 .\"WORD: calling thread 呼び出しスレッド
27 .\"WORD: signal action シグナルアクション
28 .\"WORD: signal handler シグナルハンドラ
31 .TH PTHREAD_SIGNAL 3 LinuxThreads
35 .\"O pthread_sigmask, pthread_kill, sigwait \- handling of signals in threads
37 pthread_sigmask, pthread_kill, sigwait \- スレッド内でのシグナルハンドリング
41 .B #include <pthread.h>
43 .B #include <signal.h>
45 .BI "int pthread_sigmask(int " how ", const sigset_t *" newmask ", sigset_t *" oldmask ");"
47 .BI "int pthread_kill(pthread_t " thread ", int " signo ");"
49 .BI "int sigwait(const sigset_t *" set ", int *" sig ");"
54 .\"O .B "pthread_sigmask"
55 .\"O changes the signal mask for the calling thread as
64 .\"O the previous signal mask is stored in the location pointed to
81 .\"O The meaning of the
85 .\"O arguments is the same as for
86 .\"O .BR "sigprocmask" (2).
90 .\"O .BR "SIG_SETMASK" ,
91 .\"O the signal mask is set to
96 .\"O .BR "SIG_BLOCK" ,
97 .\"O the signals specified to
99 .\"O are added to the current signal mask. If
102 .\"O .BR "SIG_UNBLOCK" ,
104 .\"O signals specified to
106 .\"O are removed from the current signal
113 .BR "sigprocmask" (2)
127 で指定されるシグナルが現時点のシグナルマスクに追加される。
133 で指定されるシグナルが現時点のシグナルマスクから取り除かれる。
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),
139 .\"O between all threads.
140 シグナルマスクはスレッドごとに設定されることを思い出してほしい。
147 .\"O .B "pthread_kill"
148 .\"O send signal number
152 .\"O The signal is delivered and handled as described in
163 に書かれているように配送されハンドルされる。
166 .\"O suspends the calling thread until one of the signals
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
173 .\"O returns. The signals in
175 .\"O must be blocked and not ignored on
178 .\"O If the delivered signal has a signal handler
179 .\"O function attached, that function is
185 で指定されるシグナルのうちいずれか 1 つが呼び出しスレッドに
186 配送されるまで呼び出しスレッドの実行を停止する。
193 に入るときにブロックされていなければならず、無視されてはならない。
194 配送されたシグナルに対するシグナルハンドラが登録されていても、
199 .\"O .SH CANCELLATION
203 .\"O is a cancellation point.
207 .\"O .SH "RETURN VALUE"
210 .\"O On success, 0 is returned. On failure, a non-zero error code is returned.
212 失敗の場合、非 0 のエラーコードが返る。
218 .\"O .B "pthread_sigmask"
219 .\"O function returns the following error codes
226 .\"O .BR "SIG_SETMASK" ,
227 .\"O .BR "SIG_BLOCK" ,
229 .\"O .B "SIG_UNBLOCK"
232 はエラーのとき、次のようなエラーコードを返す:
250 .\"O point to invalid addresses
261 .\"O .B "pthread_kill"
262 .\"O function returns the following error codes
268 .\"O is not a valid signal number
271 はエラーのとき、次のようなエラーコードを返す:
282 .\"O does not exist (e.g. it has already terminated)
288 は存在しない (例えば、そのスレッドはすでに終了している) 。
293 .\"O function never returns an error.
300 Xavier Leroy <Xavier.Leroy@inria.fr>
304 .BR "sigprocmask" (2),
307 .BR "sigsuspend" (2).
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
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
326 配送を待つシグナルは、呼び出しスレッドだけでなく
327 すべてのスレッドでブロックされていなければならない。
328 そうでない場合、POSIX のシグナル配送機構は
331 を呼び出しているスレッドとなることを保証しない。
333 どのスレッドを生成するよりも前にそれらのシグナルをブロックし、
336 を呼び出す以外、ブロックを解除しないことである。
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 つのスレッドに配送される。
352 その時点でシグナルをブロックしていないスレッドのいずれかとなる。
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
359 .\"O signal, it will not be restarted.
361 それぞれのスレッドが実際には固有の PID をもつカーネルプロセスであるため、
362 外部のシグナルは特定の 1 つのスレッドに直接配送される。
368 .\"O The LinuxThreads implementation of
370 .\"O installs dummy signal
371 .\"O handlers for the signals in
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).
379 の LinuxThreads の実装では、
383 に含まれるシグナルに対応するダミーのシグナルハンドラを登録する。
384 シグナルハンドラはすべてのスレッドで共通であるため、
385 他のスレッドはこれらのシグナルに対して独自のシグナルハンドラを登録してはならない。
387 これらのシグナルをブロックしなければならない
388 (このことはとにかく推奨されている -- 注意のセクションを参照のこと) 。