OSDN Git Service

4caa29b763c8aea8fc02ed9ba3ab9ca452c72b6a
[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)