sigwaitinfoのヘルプ・マニュアル
日本語 英語
sigwaitinfo --help
man sigwaitinfo
SIGWAITINFO(2) Linux Programmer’s Manual SIGWAITINFO(2)
名前
sigwaitinfo, sigtimedwait - キューに入れられたシグナルを同期して待つ
書式
#include
int sigwaitinfo(const sigset_t *set, siginfo_t *info);
int sigtimedwait(const sigset_t *set, siginfo_t *info,
const struct timespec *timeout);
glibc 向けの機能検査マクロの要件 (feature_test_macros(7) 参照):
sigwaitinfo(), sigtimedwait(): _POSIX_C_SOURCE >= 199309L
説明
sigwaitinfo() は set のうちのどれかのシグナルが配送されるまで、呼び出し
スレッドの実行を一時停止する (呼び出しスレッドに対して set のうちのどれ
か のシグナルが既に待機中 (pending) である場合、 sigwaitinfo() はそのシ
グナルの情報を返してすぐに戻る)。
sigwaitinfo() は配送されたシグナルを待機中のシグナルの集合から削除し 、
関 数の結果としてシグナル番号を返す。 info 引き数が NULL でない場合、配
送されたシグナルの情報が入った siginfo_t 型 (sigaction(2) を参照) の 構
造体を返す。
sigwaitinfo() で返されるシグナルは、通常の順番で配送される。詳細は sig-
nal(7) を参照すること。
sigtimedwait() は、 sigwaitinfo() と次の点を除いて全く同じように動作 す
る 。この関数にはもう 1 つの引き数 timeout があり、スレッドが一時停止す
る時間の上限を定めることができる。この引き数の型は以下のとおりである:
struct timespec {
long tv_sec; /* 秒 */
long tv_nsec; /* ナノ秒 */
}
この構造体の 2 つのフィールドがともに 0 の場合、ポーリングが行わ れ る:
sigtimedwait() は、呼び出し側プロセスに対して待機しているシグナルの情報
を返して戻るか、 set のうちのどのシグナルも待機していない場合はエラーを
返して戻る。
返り値
成功した場合、 sigwaitinfo() と sigtimedwait() はシグナル番号 (すなわち
0 より大きい数) を返す。失敗した場合、2 つの関数は -1 を返し、 errno は
エラーを表す値に設定される。
エラー
EAGAIN set のうちのどのシグナルも sigtimedwait() に指定された timeout
の期間内に配送されなかった。
EINTR シグナル待ちがシグナルハンドラによって中断 (interrupt) された (
こ の ハンドラは set にあるシグナル以外のものである)。 signal(7)
参照。
EINVAL timeout が不正である。
準拠
POSIX.1-2001.
注意
通常の使用法では、呼び出し側プロセスはこれらの関数よ り 先 に sigproc-
mask(2) の呼び出すことにより set に含まれるシグナルをブロックし (そのた
めにこれらのシグナルがこの後に続く sigwaitinfo() や sigtimedwait() の呼
び出しの間に配送された場合には、デフォルトの配置は行われず)、これらのシ
グナルに対するハンドラは設定しない。マルチスレッドプログラムでは、 sig-
waitinfo() や sigtimedwait() を呼び出したスレッド以外のスレッドにそのシ
グナルが配送されないように、全てのスレッドで該当シグナルをブロックす べ
きである。
指 定されたスレッドに対する処理待ちのシグナルの集合は、そのスレッド自体
宛ての処理待ちのシグナル集合と、プロセス全体宛ての処理待ちのシグナル 集
合をあわせたものである (signal(7) 参照)。
一つのプロセス内の複数のスレッドが sigwaitinfo() や sigtimedwait() で同
じシグナルを待って停止した場合、プロセス全体宛てのシグナルが配送され る
と 、複数のスレッドのうち一つだけが実際にそのシグナルを受信することにな
る。どのスレッドがシグナルを受信するかは決まっていない。
POSIX では sigtimedwait() の引き数 timeout の値を NULL にした場合の意味
を未定義としている。 sigwaitinfo() を呼び出したのと同じ意味としてもよい
ことになっており、実際 Linux ではこのように動作する。
Linux では、 sigwaitinfo() は sigtimedwait() を用いて実装されたライブラ
リ関数である。
関連項目
kill(2), sigaction(2), signal(2), signalfd(2), sigpending(2), sigproc-
mask(2), sigqueue(2), sigsetops(3), sigwait(3), signal(7), time(7)
Linux 2008-10-04 SIGWAITINFO(2)
SIGWAITINFO(2) Linux Programmer’s Manual SIGWAITINFO(2)
NAME
sigwaitinfo, sigtimedwait - synchronously wait for queued signals
SYNOPSIS
#include
int sigwaitinfo(const sigset_t *set, siginfo_t *info);
int sigtimedwait(const sigset_t *set, siginfo_t *info,
const struct timespec *timeout);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
sigwaitinfo(), sigtimedwait(): _POSIX_C_SOURCE >= 199309L
DESCRIPTION
sigwaitinfo() suspends execution of the calling thread until one of the
signals in set is delivered. (If one of the signals in set is already
pending for the calling thread, sigwaitinfo() will return immediately
with information about that signal.)
sigwaitinfo() removes the delivered signal from the set of pending sig-
nals and returns the signal number as its function result. If the info
argument is not NULL, then it returns a structure of type siginfo_t
(see sigaction(2)) containing information about the signal.
Signals returned via sigwaitinfo() are delivered in the usual order;
see signal(7) for further details.
sigtimedwait() operates in exactly the same way as sigwaitinfo() except
that it has an additional argument, timeout, which enables an upper
bound to be placed on the time for which the thread is suspended. This
argument is of the following type:
struct timespec {
long tv_sec; /* seconds */
long tv_nsec; /* nanoseconds */
}
If both fields of this structure are specified as 0, a poll is per-
formed: sigtimedwait() returns immediately, either with information
about a signal that was pending for the caller, or with an error if
none of the signals in set was pending.
RETURN VALUE
On success, both sigwaitinfo() and sigtimedwait() return a signal num-
ber (i.e., a value greater than zero). On failure both calls return
-1, with errno set to indicate the error.
ERRORS
EAGAIN No signal in set was delivered within the timeout period speci-
fied to sigtimedwait().
EINTR The wait was interrupted by a signal handler; see signal(7).
(This handler was for a signal other than one of those in set.)
EINVAL timeout was invalid.
CONFORMING TO
POSIX.1-2001.
NOTES
In normal usage, the calling program blocks the signals in set via a
prior call to sigprocmask(2) (so that the default disposition for these
signals does not occur if they are delivered between successive calls
to sigwaitinfo() or sigtimedwait()) and does not establish handlers for
these signals. In a multithreaded program, the signal should be
blocked in all threads to prevent the signal being delivered to a
thread other than the one calling sigwaitinfo() or sigtimedwait()).
The set of signals that is pending for a given thread is the union of
the set of signals that is pending specifically for that thread and the
set of signals that is pending for the process as a whole (see sig-
nal(7)).
If multiple threads of a process are blocked waiting for the same sig-
nal(s) in sigwaitinfo() or sigtimedwait(), then exactly one of the
threads will actually receive the signal if it is delivered to the pro-
cess as a whole; which of the threads receives the signal is indetermi-
nate.
POSIX leaves the meaning of a NULL value for the timeout argument of
sigtimedwait() unspecified, permitting the possibility that this has
the same meaning as a call to sigwaitinfo(), and indeed this is what is
done on Linux.
On Linux, sigwaitinfo() is a library function implemented on top of
sigtimedwait().
SEE ALSO
kill(2), sigaction(2), signal(2), signalfd(2), sigpending(2), sigproc-
mask(2), sigqueue(2), sigsetops(3), sigwait(3), signal(7), time(7)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2008-10-04 SIGWAITINFO(2)