OSDN Git Service

d384c1c51753edd03ef2ff79f12286c7a9c18769
[linuxjm/LDP_man-pages.git] / draft / man2 / sigwaitinfo.2
1 .\" Copyright (c) 2002 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" 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 this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Japanese Version Copyright (c) 2003 Yuichi SATO
24 .\"         all rights reserved.
25 .\" Translated 2003-02-16, Yuichi SATO <ysato444@yahoo.co.jp>
26 .\" Updated 2006-07-21, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.36
27 .\" Updated 2008-08-07, Akihiro MOTOKI, LDP v3.05
28 .\"
29 .\"WORD:        pending         待機中である
30 .\"
31 .TH SIGWAITINFO 2 2011-10-03 "Linux" "Linux Programmer's Manual"
32 .\"O .SH NAME
33 .SH 名前
34 .\"O sigwaitinfo, sigtimedwait \- synchronously wait for queued signals
35 sigwaitinfo, sigtimedwait \- キューに入れられたシグナルを同期して待つ
36 .\"O .SH SYNOPSIS
37 .SH 書式
38 .nf
39 .B #include <signal.h>
40 .sp
41 .BI "int sigwaitinfo(const sigset_t *" set ", siginfo_t *" info ");"
42 .sp
43 .BI "int sigtimedwait(const sigset_t *" set ", siginfo_t *" info ", "
44 .BI "                 const struct timespec *" timeout ");"
45 .fi
46 .sp
47 .in -4n
48 .\"O Feature Test Macro Requirements for glibc (see
49 .\"O .BR feature_test_macros (7)):
50 glibc 向けの機能検査マクロの要件
51 .RB ( feature_test_macros (7)
52 参照):
53 .in
54 .sp
55 .BR sigwaitinfo (),
56 .BR sigtimedwait ():
57 _POSIX_C_SOURCE\ >=\ 199309L
58 .\"O .SH DESCRIPTION
59 .SH 説明
60 .\"O .BR sigwaitinfo ()
61 .\"O suspends execution of the calling thread until one of the signals in
62 .\"O .I set
63 .\"O is delivered.
64 .BR sigwaitinfo ()
65
66 .I set
67 のうちのどれかのシグナルが配送されるまで、
68 呼び出しスレッドの実行を一時停止する
69 .\"O (If one of the signals in
70 .\"O .I set
71 .\"O is already pending for the calling thread,
72 .\"O .BR sigwaitinfo ()
73 .\"O will return immediately with information about that signal.)
74 (呼び出しスレッドに対して
75 .I set
76 のうちのどれかのシグナルが既に待機中 (pending) である場合、
77 .BR sigwaitinfo ()
78 はそのシグナルの情報を返してすぐに戻る)。
79 .PP
80 .\"O .BR sigwaitinfo ()
81 .\"O removes the delivered signal from the set of pending
82 .\"O signals and returns the signal number as its function result.
83 .BR sigwaitinfo ()
84 は配送されたシグナルを待機中のシグナルの集合から削除し、
85 関数の結果としてシグナル番号を返す。
86 .\"O If the
87 .\"O .I info
88 .\"O argument is not NULL,
89 .\"O then it returns a structure of type
90 .\"O .I siginfo_t
91 .\"O (see
92 .\"O .BR sigaction (2))
93 .\"O containing information about the signal.
94 .I info
95 引き数が NULL でない場合、配送されたシグナルの情報が入った
96 .I siginfo_t
97
98 .RB ( sigaction (2)
99 を参照) の構造体を返す。
100 .PP
101 .\"O Signals returned via
102 .\"O .BR sigwaitinfo ()
103 .\"O are delivered in the usual order; see
104 .\"O .BR signal (7)
105 .\"O for further details.
106 .BR sigwaitinfo ()
107 で返されるシグナルは、通常の順番で配送される。
108 詳細は
109 .BR signal (7)
110 を参照すること。
111 .PP
112 .\"O .BR sigtimedwait ()
113 .\"O operates in exactly the same way as
114 .\"O .BR sigwaitinfo ()
115 .\"O except that it has an additional argument,
116 .\"O .IR timeout ,
117 .\"O which enables an upper bound to be placed on the time for which
118 .\"O the thread is suspended.
119 .BR sigtimedwait ()
120 は、
121 .BR sigwaitinfo ()
122 と次の点を除いて全く同じように動作する。
123 この関数にはもう 1 つの引き数
124 .I timeout
125 があり、スレッドが一時停止する時間の上限を定めることができる。
126 .\"O This argument is of the following type:
127 この引き数の型は以下のとおりである:
128 .sp
129 .in +4n
130 .nf
131 struct timespec {
132 .\"O     long    tv_sec;         /* seconds */
133     long    tv_sec;         /* 秒 */
134 .\"O     long    tv_nsec;        /* nanoseconds */
135     long    tv_nsec;        /* ナノ秒 */
136 }
137 .fi
138 .in
139 .sp
140 .\"O If both fields of this structure are specified as 0, a poll is performed:
141 この構造体の 2 つのフィールドがともに 0 の場合、ポーリングが行われる:
142 .\"O .BR sigtimedwait ()
143 .\"O returns immediately, either with information about a signal that
144 .\"O was pending for the caller, or with an error
145 .\"O if none of the signals in
146 .\"O .I set
147 .\"O was pending.
148 .BR sigtimedwait ()
149 は、呼び出し側プロセスに対して
150 待機しているシグナルの情報を返して戻るか、
151 .I set
152 のうちのどのシグナルも待機していない場合はエラーを返して戻る。
153 .\"O .SH "RETURN VALUE"
154 .SH 返り値
155 .\"O On success, both
156 .\"O .BR sigwaitinfo ()
157 .\"O and
158 .\"O .BR sigtimedwait ()
159 .\"O return a signal number (i.e., a value greater than zero).
160 成功した場合、
161 .BR sigwaitinfo ()
162
163 .BR sigtimedwait ()
164 はシグナル番号 (すなわち 0 より大きい数) を返す。
165 .\"O On failure both calls return \-1, with
166 .\"O .I errno
167 .\"O set to indicate the error.
168 失敗した場合、2 つの関数は \-1 を返し、
169 .I errno
170 はエラーを表す値に設定される。
171 .\"O .SH ERRORS
172 .SH エラー
173 .TP
174 .B EAGAIN
175 .\"O No signal in
176 .\"O .I set
177 .\"O was delivered within the
178 .\"O .I timeout
179 .\"O period specified to
180 .\"O .BR sigtimedwait ().
181 .I set
182 のうちのどのシグナルも
183 .BR sigtimedwait ()
184 に指定された
185 .I timeout
186 の期間内に配送されなかった。
187 .TP
188 .B EINTR
189 .\"O The wait was interrupted by a signal handler; see
190 .\"O .BR signal (7).
191 .\"O (This handler was for a signal other than one of those in
192 .\"O .IR set .)
193 シグナル待ちがシグナルハンドラによって中断 (interrupt) された
194 (このハンドラは
195 .I set
196 にあるシグナル以外のものである)。
197 .BR signal (7)
198 参照。
199 .TP
200 .B EINVAL
201 .\"O .I timeout
202 .\"O was invalid.
203 .I timeout
204 が不正である。
205 .\"O .SH "CONFORMING TO"
206 .SH 準拠
207 POSIX.1-2001.
208 .\"O .SH NOTES
209 .SH 注意
210 .\"O In normal usage, the calling program blocks the signals in
211 .\"O .I set
212 .\"O via a prior call to
213 .\"O .BR sigprocmask (2)
214 .\"O (so that the default disposition for these signals does not occur if they
215 .\"O are delivered between successive calls to
216 .\"O .BR sigwaitinfo ()
217 .\"O or
218 .\"O .BR sigtimedwait())
219 .\"O and does not establish handlers for these signals.
220 通常の使用法では、呼び出し側プロセスはこれらの関数より先に
221 .BR sigprocmask (2)
222 の呼び出すことにより
223 .I set
224 に含まれるシグナルをブロックし
225 (そのためにこれらのシグナルがこの後に続く
226 .BR sigwaitinfo ()
227
228 .BR sigtimedwait ()
229 の呼び出しの間に配送された場合には、
230 デフォルトの配置は行われず)、
231 これらのシグナルに対するハンドラは設定しない。
232 .\"O In a multithreaded program,
233 .\"O the signal should be blocked in all threads to prevent
234 .\"O the signal being delivered to a thread other than the one calling
235 .\"O .BR sigwaitinfo ()
236 .\"O or
237 .\"O .BR sigtimedwait ()).
238 マルチスレッドプログラムでは、
239 .BR sigwaitinfo ()
240
241 .BR sigtimedwait ()
242 を呼び出したスレッド以外のスレッドにそのシグナルが配送されないように、
243 全てのスレッドで該当シグナルをブロックすべきである。
244
245 .\"O The set of signals that is pending for a given thread is the
246 .\"O union of the set of signals that is pending specifically for that thread
247 .\"O and the set of signals that is pending for the process as a whole (see
248 .\"O .BR signal (7)).
249 指定されたスレッドに対する処理待ちのシグナルの集合は、
250 そのスレッド自体宛ての処理待ちのシグナル集合と、プロセス全体宛ての
251 処理待ちのシグナル集合をあわせたものである
252 .RB ( signal (7)
253 参照)。
254
255 .\"O Attempts to wait for
256 .\"O .B SIGKILL
257 .\"O and
258 .\"O .B SIGSTOP
259 .\"O are silently ignored.
260 .B SIGKILL
261
262 .B SIGSTOP
263 を待とうとした場合、黙って無視される。
264
265 .\"O If multiple threads of a process are blocked
266 .\"O waiting for the same signal(s) in
267 .\"O .BR sigwaitinfo ()
268 .\"O or
269 .\"O .BR sigtimedwait (),
270 .\"O then exactly one of the threads will actually receive the
271 .\"O signal if it is delivered to the process as a whole;
272 .\"O which of the threads receives the signal is indeterminate.
273 一つのプロセス内の複数のスレッドが
274 .BR sigwaitinfo ()
275
276 .BR sigtimedwait ()
277 で同じシグナルを待って停止した場合、
278 プロセス全体宛てのシグナルが配送されると、複数のスレッドのうち一つだけが
279 実際にそのシグナルを受信することになる。
280 どのスレッドがシグナルを受信するかは決まっていない。
281
282 .\"O POSIX leaves the meaning of a NULL value for the
283 .\"O .I timeout
284 .\"O argument of
285 .\"O .BR sigtimedwait ()
286 .\"O unspecified, permitting the possibility that this has the same meaning
287 .\"O as a call to
288 .\"O .BR sigwaitinfo (),
289 .\"O and indeed this is what is done on Linux.
290 POSIX では
291 .BR sigtimedwait ()
292 の引き数
293 .I timeout
294 の値を NULL にした場合の意味を未定義としている。
295 .BR sigwaitinfo ()
296 を呼び出したのと同じ意味としてもよいことになっており、
297 実際 Linux ではこのように動作する。
298
299 .\"O On Linux,
300 .\"O .BR sigwaitinfo ()
301 .\"O is a library function implemented on top of
302 .\"O .BR sigtimedwait ().
303 Linux では、
304 .BR sigwaitinfo ()
305
306 .BR sigtimedwait ()
307 を用いて実装されたライブラリ関数である。
308 .\"O .SH "SEE ALSO"
309 .SH 関連項目
310 .BR kill (2),
311 .BR sigaction (2),
312 .BR signal (2),
313 .BR signalfd (2),
314 .BR sigpending (2),
315 .BR sigprocmask (2),
316 .BR sigqueue (3),
317 .BR sigsetops (3),
318 .BR sigwait (3),
319 .BR signal (7),
320 .BR time (7)