.\" Copyright (c) 2002 Michael Kerrisk .\" .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" .\" Japanese Version Copyright (c) 2003 Yuichi SATO .\" all rights reserved. .\" Translated 2003-02-16, Yuichi SATO .\" Updated 2006-07-21, Akihiro MOTOKI , LDP v2.36 .\" Updated 2008-08-07, Akihiro MOTOKI, LDP v3.05 .\" .\"WORD: pending 待機中である .\" .TH SIGWAITINFO 2 2008-10-04 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O sigwaitinfo, sigtimedwait \- synchronously wait for queued signals sigwaitinfo, sigtimedwait \- キューに入れられたシグナルを同期して待つ .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .sp .BI "int sigwaitinfo(const sigset_t *" set ", siginfo_t *" info ");" .sp .BI "int sigtimedwait(const sigset_t *" set ", siginfo_t *" info ", " .BI " const struct timespec *" timeout ");" .fi .sp .in -4n .\"O Feature Test Macro Requirements for glibc (see .\"O .BR feature_test_macros (7)): glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .BR sigwaitinfo (), .BR sigtimedwait (): _POSIX_C_SOURCE\ >=\ 199309L .\"O .SH DESCRIPTION .SH 説明 .\"O .BR sigwaitinfo () .\"O suspends execution of the calling thread until one of the signals in .\"O .I set .\"O is delivered. .BR sigwaitinfo () は .I set のうちのどれかのシグナルが配送されるまで、 呼び出しスレッドの実行を一時停止する .\"O (If one of the signals in .\"O .I set .\"O is already pending for the calling thread, .\"O .BR sigwaitinfo () .\"O will return immediately with information about that signal.) (呼び出しスレッドに対して .I set のうちのどれかのシグナルが既に待機中 (pending) である場合、 .BR sigwaitinfo () はそのシグナルの情報を返してすぐに戻る)。 .PP .\"O .BR sigwaitinfo () .\"O removes the delivered signal from the set of pending .\"O signals and returns the signal number as its function result. .BR sigwaitinfo () は配送されたシグナルを待機中のシグナルの集合から削除し、 関数の結果としてシグナル番号を返す。 .\"O If the .\"O .I info .\"O argument is not NULL, .\"O then it returns a structure of type .\"O .I siginfo_t .\"O (see .\"O .BR sigaction (2)) .\"O containing information about the signal. .I info 引き数が NULL でない場合、配送されたシグナルの情報が入った .I siginfo_t 型 .RB ( sigaction (2) を参照) の構造体を返す。 .PP .\"O Signals returned via .\"O .BR sigwaitinfo () .\"O are delivered in the usual order; see .\"O .BR signal (7) .\"O for further details. .BR sigwaitinfo () で返されるシグナルは、通常の順番で配送される。 詳細は .BR signal (7) を参照すること。 .PP .\"O .BR sigtimedwait () .\"O operates in exactly the same way as .\"O .BR sigwaitinfo () .\"O except that it has an additional argument, .\"O .IR timeout , .\"O which enables an upper bound to be placed on the time for which .\"O the thread is suspended. .BR sigtimedwait () は、 .BR sigwaitinfo () と次の点を除いて全く同じように動作する。 この関数にはもう 1 つの引き数 .I timeout があり、スレッドが一時停止する時間の上限を定めることができる。 .\"O This argument is of the following type: この引き数の型は以下のとおりである: .sp .in +4n .nf struct timespec { .\"O long tv_sec; /* seconds */ long tv_sec; /* 秒 */ .\"O long tv_nsec; /* nanoseconds */ long tv_nsec; /* ナノ秒 */ } .fi .in .sp .\"O If both fields of this structure are specified as 0, a poll is performed: この構造体の 2 つのフィールドがともに 0 の場合、ポーリングが行われる: .\"O .BR sigtimedwait () .\"O returns immediately, either with information about a signal that .\"O was pending for the caller, or with an error .\"O if none of the signals in .\"O .I set .\"O was pending. .BR sigtimedwait () は、呼び出し側プロセスに対して 待機しているシグナルの情報を返して戻るか、 .I set のうちのどのシグナルも待機していない場合はエラーを返して戻る。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O On success, both .\"O .BR sigwaitinfo () .\"O and .\"O .BR sigtimedwait () .\"O return a signal number (i.e., a value greater than zero). 成功した場合、 .BR sigwaitinfo () と .BR sigtimedwait () はシグナル番号 (すなわち 0 より大きい数) を返す。 .\"O On failure both calls return \-1, with .\"O .I errno .\"O set to indicate the error. 失敗した場合、2 つの関数は \-1 を返し、 .I errno はエラーを表す値に設定される。 .\"O .SH ERRORS .SH エラー .TP .B EAGAIN .\"O No signal in .\"O .I set .\"O was delivered within the .\"O .I timeout .\"O period specified to .\"O .BR sigtimedwait (). .I set のうちのどのシグナルも .BR sigtimedwait () に指定された .I timeout の期間内に配送されなかった。 .TP .B EINTR .\"O The wait was interrupted by a signal handler; see .\"O .BR signal (7). .\"O (This handler was for a signal other than one of those in .\"O .IR set .) シグナル待ちがシグナルハンドラによって中断 (interrupt) された (このハンドラは .I set にあるシグナル以外のものである)。 .BR signal (7) 参照。 .TP .B EINVAL .\"O .I timeout .\"O was invalid. .I timeout が不正である。 .\"O .SH "CONFORMING TO" .SH 準拠 POSIX.1-2001. .\"O .SH NOTES .SH 注意 .\"O In normal usage, the calling program blocks the signals in .\"O .I set .\"O via a prior call to .\"O .BR sigprocmask (2) .\"O (so that the default disposition for these signals does not occur if they .\"O are delivered between successive calls to .\"O .BR sigwaitinfo () .\"O or .\"O .BR sigtimedwait()) .\"O and does not establish handlers for these signals. 通常の使用法では、呼び出し側プロセスはこれらの関数より先に .BR sigprocmask (2) の呼び出すことにより .I set に含まれるシグナルをブロックし (そのためにこれらのシグナルがこの後に続く .BR sigwaitinfo () や .BR sigtimedwait () の呼び出しの間に配送された場合には、 デフォルトの配置は行われず)、 これらのシグナルに対するハンドラは設定しない。 .\"O In a multithreaded program, .\"O the signal should be blocked in all threads to prevent .\"O the signal being delivered to a thread other than the one calling .\"O .BR sigwaitinfo () .\"O or .\"O .BR sigtimedwait ()). マルチスレッドプログラムでは、 .BR sigwaitinfo () や .BR sigtimedwait () を呼び出したスレッド以外のスレッドにそのシグナルが配送されないように、 全てのスレッドで該当シグナルをブロックすべきである。 .\"O The set of signals that is pending for a given thread is the .\"O union of the set of signals that is pending specifically for that thread .\"O and the set of signals that is pending for the process as a whole (see .\"O .BR signal (7)). 指定されたスレッドに対する処理待ちのシグナルの集合は、 そのスレッド自体宛ての処理待ちのシグナル集合と、プロセス全体宛ての 処理待ちのシグナル集合をあわせたものである .RB ( signal (7) 参照)。 .\"O If multiple threads of a process are blocked .\"O waiting for the same signal(s) in .\"O .BR sigwaitinfo () .\"O or .\"O .BR sigtimedwait (), .\"O then exactly one of the threads will actually receive the .\"O signal if it is delivered to the process as a whole; .\"O which of the threads receives the signal is indeterminate. 一つのプロセス内の複数のスレッドが .BR sigwaitinfo () や .BR sigtimedwait () で同じシグナルを待って停止した場合、 プロセス全体宛てのシグナルが配送されると、複数のスレッドのうち一つだけが 実際にそのシグナルを受信することになる。 どのスレッドがシグナルを受信するかは決まっていない。 .\"O POSIX leaves the meaning of a NULL value for the .\"O .I timeout .\"O argument of .\"O .BR sigtimedwait () .\"O unspecified, permitting the possibility that this has the same meaning .\"O as a call to .\"O .BR sigwaitinfo (), .\"O and indeed this is what is done on Linux. POSIX では .BR sigtimedwait () の引き数 .I timeout の値を NULL にした場合の意味を未定義としている。 .BR sigwaitinfo () を呼び出したのと同じ意味としてもよいことになっており、 実際 Linux ではこのように動作する。 .\"O On Linux, .\"O .BR sigwaitinfo () .\"O is a library function implemented on top of .\"O .BR sigtimedwait (). Linux では、 .BR sigwaitinfo () は .BR sigtimedwait () を用いて実装されたライブラリ関数である。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR kill (2), .BR sigaction (2), .BR signal (2), .BR signalfd (2), .BR sigpending (2), .BR sigprocmask (2), .BR sigqueue (2), .BR sigsetops (3), .BR sigwait (3), .BR signal (7), .BR time (7)