OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[linuxjm/LDP_man-pages.git] / release / man2 / poll.2
1 .\" Hey Emacs! This file is -*- nroff -*- source.
2 .\"
3 .\" Copyright (C) 1997 Andries Brouwer (aeb@cwi.nl)
4 .\" and Copyright (C) 2006, Michael Kerrisk <mtk.manpages@gmail.com>
5 .\"
6 .\" Permission is granted to make and distribute verbatim copies of this
7 .\" manual provided the copyright notice and this permission notice are
8 .\" preserved on all copies.
9 .\"
10 .\" Permission is granted to copy and distribute modified versions of this
11 .\" manual under the conditions for verbatim copying, provided that the
12 .\" entire resulting derived work is distributed under the terms of a
13 .\" permission notice identical to this one.
14 .\"
15 .\" Since the Linux kernel and libraries are constantly changing, this
16 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
17 .\" responsibility for errors or omissions, or for damages resulting from
18 .\" the use of the information contained herein.  The author(s) may not
19 .\" have taken the same level of care in the production of this manual,
20 .\" which is licensed free of charge, as they might when working
21 .\" professionally.
22 .\"
23 .\" Formatted or processed versions of this manual, if unaccompanied by
24 .\" the source, must acknowledge the copyright and authors of this work.
25 .\"
26 .\" Additions from Richard Gooch <rgooch@atnf.CSIRO.AU> and aeb, 971207
27 .\" 2006-03-13, mtk, Added ppoll() + various other rewordings
28 .\" 2006-07-01, mtk, Added POLLRDHUP + various other wording and
29 .\"     formatting changes.
30 .\"
31 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
32 .\"         all rights reserved.
33 .\" Translated 1997-12-11, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
34 .\" Updated & Modified 2004-05-22, Yuichi SATO <ysato444@yahoo.co.jp>
35 .\" Updated & Modified 2005-01-03, Yuichi SATO
36 .\" Updated & Modified 2005-10-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
37 .\" Updated 2005-12-05, Akihiro MOTOKI, Catch up to LDP man-pages 2.16
38 .\" Updated 2006-04-16, Akihiro MOTOKI, Catch up to LDP man-pages 2.28
39 .\" Updated 2006-07-23, Akihiro MOTOKI, Catch up to LDP man-pages 2.36
40 .\"
41 .\"WORD:        descriptor              ¥Ç¥£¥¹¥¯¥ê¥×¥¿
42 .\"
43 .TH POLL 2 2009-09-15 "Linux" "Linux Programmer's Manual"
44 .SH Ì¾Á°
45 poll, ppoll \- ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë¤ª¤±¤ë¥¤¥Ù¥ó¥È¤òÂÔ¤Ä
46 .SH ½ñ¼°
47 .nf
48 .B #include <poll.h>
49 .sp
50 .BI "int poll(struct pollfd *" fds ", nfds_t " nfds ", int " timeout );
51 .sp
52 .B #define _GNU_SOURCE
53 .B #include <poll.h>
54 .sp
55 .BI "int ppoll(struct pollfd *" fds ", nfds_t " nfds ", "
56 .BI "        const struct timespec *" timeout ", const sigset_t *" sigmask );
57 .fi
58 .SH ÀâÌÀ
59 .BR poll ()
60 ¤Ï
61 .BR select (2)
62 ¤ÈƱÍͤλŻö¤ò¹Ô¤¦¡¢¤Ä¤Þ¤ê¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿½¸¹ç¤Î¤¤¤º¤ì¤«°ì¤Ä¤¬
63 I/O ¤ò¼Â¹Ô²Äǽ¤Ê¾õÂ֤ˤʤë¤Î¤òÂԤġ£
64
65 ´Æ»ë¤¹¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿½¸¹ç¤Ï¡¢
66 .I fds
67 °ú¤­¿ô¤Ç»ØÄꤹ¤ë¡£
68 .I fds
69 ¤Ï¡¢°Ê²¼¤Î·¿¤Î¹½Â¤ÂΤÎÇÛÎó¤Ç¤¢¤ë¡£
70 .in +4n
71 .nf
72
73 struct pollfd {
74     int   fd;         /* file descriptor */
75     short events;     /* requested events */
76     short revents;    /* returned events */
77 };
78 .in
79 .fi
80 .PP
81 .I nfds
82 ¤Ë¤Ï¡¢
83 .I fds
84 ÇÛÎó¤ÎÍ×ÁÇ¿ô¤ò»ØÄꤹ¤ë¡£
85
86 ¹½Â¤ÂΤÎ
87 .I fd
88 ¤Ë¤Ï¥ª¡¼¥×¥ó¤·¤¿¥Õ¥¡¥¤¥ë¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÆþ¤ì¤ë¡£
89
90 ¹½Â¤ÂΤÎ
91 .I events
92 Í×ÁǤÏÆþÎϥѥé¥á¡¼¥¿¤Ç¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤¬¶½Ì£¤ò»ý¤Ã¤Æ¤¤¤ë¥¤¥Ù¥ó¥È¤Î
93 ¥Ó¥Ã¥È¥Þ¥¹¥¯¤ò»ØÄꤹ¤ë¡£
94
95 .I revents
96 Í×ÁǤϽÐÎϥѥé¥á¡¼¥¿¤Ç¡¢¼ÂºÝ¤Ëµ¯¤³¤Ã¤¿¥¤¥Ù¥ó¥È¤¬¥«¡¼¥Í¥ë¤Ë¤è¤êÀßÄꤵ¤ì¤ë¡£
97 .I revents
98 ¤ÇÊÖ¤µ¤ì¤ë¥Ó¥Ã¥ÈÎó¤Ë¤Ï¡¢
99 .I events
100 ¤Ç»ØÄꤷ¤¿¤â¤Î¤Î¤É¤ì¤«¡¢¤â¤·¤¯¤Ï
101 .BR POLLERR ,
102 .BR POLLHUP ,
103 .B POLLNVAL
104 ¤Î¤¦¤Á¤Î°ì¤Ä¤¬´Þ¤Þ¤ì¤ë
105 .RB ( POLLERR ,
106 .BR POLLHUP ,
107 .B POLLNVAL
108 ¤Î 3¤Ä¤Î¥Ó¥Ã¥È¤Ï
109 .I events
110 ¤Ë»ØÄꤷ¤Æ¤â°ÕÌ£¤¬¤Ê¤¯¡¢Âбþ¤·¤¿¾õÂÖ¤¬¿¿¤Î¾ì¹ç¤Ë
111 .I revents
112 ¤ËÀßÄꤵ¤ì¤ë)¡£
113
114 ¤É¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ë¤âÍ׵ᤷ¤¿¥¤¥Ù¥ó¥È¤¬È¯À¸¤·¤Æ¤ª¤é¤º¡¢
115 ¥¨¥é¡¼¤âµ¯¤³¤é¤Ê¤¤¾ì¹ç¡¢
116 .BR poll ()
117 ¤Ï¥¤¥Ù¥ó¥È¤Î¤¦¤Á¤¤¤º¤ì¤«°ì¤Ä¤¬È¯À¸¤¹¤ë¤Þ¤ÇÄä»ß (block) ¤¹¤ë¡£
118
119 .I timeout
120 °ú¤­¿ô¤Ï
121 .BR poll ()
122 ¤¬Ää»ß¤¹¤ë»þ´Ö¤Î¾å¸Â¤òÀßÄꤹ¤ë¤â¤Î¤Ç¡¢¥ß¥êÉÃñ°Ì¤Ç»ØÄꤹ¤ë¡£
123 .I timeout
124 ¤ËÉé¤ÎÃͤò»ØÄꤹ¤ë¤È¡¢¥¿¥¤¥à¥¢¥¦¥È»þ´Ö¤¬Ìµ¸Â¤È¤Ê¤ë¡£
125
126 .I events
127 ¤Ë»ØÄꤷ¤¿¤ê¡¢
128 .I revents
129 ¤ÇÊÖ¤µ¤ì¤ë¥Ó¥Ã¥È¤Ï \fI<poll.h>\fP ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤ë:
130 .RS
131 .TP
132 .B POLLIN
133 Æɤ߽Ф·²Äǽ¤Ê¥Ç¡¼¥¿¤¬¤¢¤ë¡£
134 .TP
135 .B POLLPRI
136 Æɤ߽Ф·²Äǽ¤Ê¶ÛµÞ¥Ç¡¼¥¿ (urgent data) ¤¬¤¢¤ë
137 (Î㤨¤Ð¡¢TCP ¥½¥±¥Ã¥È¤ÎÂÓ°è³° (out-of-band data) ¥Ç¡¼¥¿¤ò¼õ¿®¤·¤¿¾ì¹ç¤ä¡¢
138 ¥Ñ¥±¥Ã¥È¥â¡¼¥É¤Îµ¼»÷üËö¤Î¥Þ¥¹¥¿¤¬¥¹¥ì¡¼¥Ö¦¤ÎÊѲ½¤ò¸«¤Ä¤±¤¿¤È¤­)¡£
139 .TP
140 .B POLLOUT
141 ½ñ¤­¹þ¤ß¤¬Ää»ß (block) ¤·¤Ê¤¤¾õÂ֤Ǥ¢¤ë¡£
142 .TP
143 .BR POLLRDHUP " (Linux 2.6.17 °Ê¹ß)"
144 ¥¹¥È¥ê¡¼¥à¥½¥±¥Ã¥È¤Î¾ü¤¬¡¢¥³¥Í¥¯¥·¥ç¥ó¤ò close ¤·¤¿¤«¡¢
145 ¥³¥Í¥¯¥·¥ç¥ó¤Î½ñ¤­¹þ¤ß¦¤ò shutdown ¤·¤¿¡£
146 ¤³¤ÎÄêµÁ¤òÍ­¸ú¤Ë¤¹¤ë¤Ë¤Ï¡¢
147 .B _GNU_SOURCE
148 µ¡Ç½¸¡ºº¥Þ¥¯¥í¤òÄêµÁ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
149 .TP
150 .B POLLERR
151 ¥¨¥é¡¼¾õÂÖ (½ÐÎϤξì¹ç¤Î¤ß)¡£
152 .TP
153 .B POLLHUP
154 ¥Ï¥ó¥°¥¢¥Ã¥×¤·¤¿ (½ÐÎϤξì¹ç¤Î¤ß)¡£
155 .TP
156 .B POLLNVAL
157 ÉÔÀµ¤ÊÍ×µá:
158 .I fd
159 ¤¬¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤Ê¤¤ (½ÐÎϤξì¹ç¤Î¤ß)¡£
160 .RE
161 .PP
162 .B _XOPEN_SOURCE
163 ¤òÄêµÁ¤·¤Æ¥³¥ó¥Ñ¥¤¥ë¤·¤¿¾ì¹ç¤Ë¤Ï¡¢°Ê²¼¤ÎÄêµÁ¤â¹Ô¤ï¤ì¤ë¡£
164 ¤¿¤À¤·¡¢¾åµ­¤Î¥ê¥¹¥È¤Ë¤¢¤ë¥Ó¥Ã¥È°Ê¾å¤Î¾ðÊó¤¬ÆÀ¤é¤ì¤ëÌõ¤Ç¤Ï¤Ê¤¤¡£
165 .RS
166 .TP
167 .B POLLRDNORM
168 .B POLLIN
169 ¤ÈƱ¤¸¡£
170 .TP
171 .B POLLRDBAND
172 Í¥ÀèÂÓ°è¥Ç¡¼¥¿ (priority band data) ¤¬Æɤ߽Ф·²Äǽ¤Ç¤¢¤ë
173 (ÉáÄ̤ϠLinux ¤Ç¤Ï»ÈÍѤµ¤ì¤Ê¤¤)¡£
174 .\" POLLRDBAND is used in the DECnet protocol.
175 .TP
176 .B POLLWRNORM
177 .B POLLOUT
178 ¤ÈƱ¤¸¡£
179 .TP
180 .B POLLWRBAND
181 Í¥ÀèÂÓ°è¥Ç¡¼¥¿ (priority data) ¤¬½ñ¤­¹þ¤ß²Äǽ¤Ç¤¢¤ë¡£
182 .RE
183 .PP
184 Linux ¤Ç¤Ï
185 .B POLLMSG
186 ¤âÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤¬¡¢»ÈÍѤµ¤ì¤Æ¤¤¤Ê¤¤¡£
187 .SS ppoll()
188 .BR poll ()
189 ¤È
190 .BR ppoll ()
191 ¤Î´Ø·¸¤Ï
192 .BR select (2)
193 ¤È
194 .BR pselect (2)
195 ¤Î´Ø·¸¤ÈƱ¤¸¤è¤¦¤Ê¤â¤Î¤Ç¤¢¤ë:
196 .BR pselect (2)
197 ¤ÈƱÍͤˡ¢
198 .BR ppoll ()
199 ¤ò»È¤¦¤È¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¾õÂÖÊѲ½
200 ¤â¤·¤¯¤Ï¥·¥°¥Ê¥ë¤ÎÊ᪤ò°ÂÁ´¤ËÂԤĤ³¤È¤¬¤Ç¤­¤ë¡£
201 .PP
202 .I timeout
203 °ú¤­¿ô¤Î°ã¤¤¤ò½ü¤¯¤È¡¢°Ê²¼¤Î
204 .BR ppoll ()
205 ¤Î¸Æ¤Ó½Ð¤·¤Ï¡¢
206 .nf
207
208     ready = ppoll(&fds, nfds, timeout, &sigmask);
209
210 .fi
211 ¼¡¤Î¥³¡¼¥ë¤ò
212 .I atomic
213 ¤Ë¼Â¹Ô¤¹¤ë¤Î¤ÈÅù²Á¤Ç¤¢¤ë¡£
214 .nf
215
216     sigset_t origmask;
217
218     sigprocmask(SIG_SETMASK, &sigmask, &origmask);
219     ready = poll(&fds, nfds, timeout);
220     sigprocmask(SIG_SETMASK, &origmask, NULL);
221 .fi
222 .PP
223 ¤Ê¤¼
224 .BR ppoll ()
225 ¤¬É¬ÍפʤΤ«¤Ë¤Ä¤¤¤Æ¤ÎÀâÌÀ¤Ï
226 .BR pselect (2)
227 ¤ÎÀâÌÀ¤ò»²¾È¤Î¤³¤È¡£
228
229 .I sigmask
230 °ú¤­¿ô¤Ë NULL ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢¥·¥°¥Ê¥ë¥Þ¥¹¥¯¤ÎÁàºî¤Ï¹Ô¤ï¤ì¤Ê¤¤
231 (¤·¤¿¤¬¤Ã¤Æ¡¢
232 .BR ppoll ()
233 ¤Î
234 .BR poll ()
235 ¤È¤Î°ã¤¤¤Ï
236 .I timeout
237 °ú¤­¿ô¤ÎÀºÅÙ¤À¤±¤È¤Ê¤ë)¡£
238
239 .I timeout
240 °ú¤­¿ô¤Ï
241 .BR ppoll ()
242 ¤¬Ää»ß¤¹¤ë»þ´Ö¤Î¾å¸Â¤ò»ØÄꤹ¤ë¤â¤Î¤Ç¤¢¤ë¡£
243 ¤³¤Î°ú¤­¿ô¤Ë¤Ï°Ê²¼¤Î·¿¤Î¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤ò»ØÄꤹ¤ë¡£
244 .in +4n
245 .nf
246
247 struct timespec {
248     long    tv_sec;         /* seconds */
249     long    tv_nsec;        /* nanoseconds */
250 };
251 .fi
252 .in
253
254 .I timeout
255 ¤Ë NULL ¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢
256 .B ppoll
257 ¤Ï̵¸Â¤ËÄä»ß¤¹¤ë¤³¤È¤¬¤¢¤êÆÀ¤ë¡£
258 .SH ÊÖ¤êÃÍ
259 À®¸ù¤·¤¿¾ì¹ç¤ÏÀµ¤Î¿ô¤òÊÖ¤¹¡£¤³¤Î¿ô¤Ï 0 °Ê³°¤Î
260 .I revents
261 Í×ÁǤò»ý¤Ä¹½Â¤ÂΤοô¤Ç¤¢¤ë (Ê̤θÀ¤¤Êý¤ò¤¹¤ë¤È¡¢¤³¤ì¤é¤Î¥Ç¥£¥¹¥¯¥ê¥×¥¿
262 ¤Ë¤Ï¥¤¥Ù¥ó¥È¤«¥¨¥é¡¼Êó¹ð¤¬¤¢¤ë)¡£
263 ÃÍ 0 ¤Ï¡¢¥¿¥¤¥à¥¢¥¦¥È¤È¤Ê¤ê¡¢¤É¤Î¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤â¥¤¥Ù¥ó¥È¤¬
264 ȯÀ¸¤·¤Ê¤«¤Ã¤¿¤³¤È¤ò¼¨¤¹¡£¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤¬ÊÖ¤µ¤ì¡¢
265 .I errno
266 ¤¬Å¬ÀÚ¤ËÀßÄꤵ¤ì¤ë¡£
267 .SH ¥¨¥é¡¼
268 .TP
269 .B EFAULT
270 °ú¤­¿ô¤È¤·¤Æ»ØÄꤷ¤¿ÇÛÎ󤬡¢¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¥¢¥É¥ì¥¹¶õ´Ö¤Ë
271 ´Þ¤Þ¤ì¤Æ¤¤¤Ê¤¤¡£
272 .TP
273 .B EINTR
274 Í׵ᤵ¤ì¤¿¥¤¥Ù¥ó¥È¤Î¤É¤ì¤«¤¬µ¯¤³¤ëÁ°¤Ë¥·¥°¥Ê¥ë¤¬È¯À¸¤·¤¿¡£
275 .BR signal (7)
276 »²¾È¡£
277 .TP
278 .B EINVAL
279 .I nfds
280 ¤ÎÃͤ¬
281 .B RLIMIT_NOFILE
282 ¤òĶ¤¨¤¿¡£
283 .TP
284 .B ENOMEM
285 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¡¦¥Æ¡¼¥Ö¥ë¤ò³ÎÊݤ¹¤ë¤¿¤á¤Î¥á¥â¥ê¤¬¤Ê¤¤¡£
286 .SH ¥Ð¡¼¥¸¥ç¥ó
287 .BR poll ()
288 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux 2.1.23 ¤ÇƳÆþ¤µ¤ì¤¿¡£
289 .BR poll ()
290 ¥é¥¤¥Ö¥é¥ê¡¦¥³¡¼¥ë¤Ï libc 5.4.28 ¤«¤éƳÆþ¤µ¤ì¤¿
291 (¤³¤ì¤Ï¥«¡¼¥Í¥ë¤¬
292 .BR poll ()
293 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë
294 .BR select (2)
295 ¤ò»ÈÍѤ·¤Æ¥¨¥ß¥å¥ì¡¼¥È¤ò¹Ô¤¦)¡£
296
297 .BR ppoll ()
298 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï ¥«¡¼¥Í¥ë 2.6.16 ¤Ç Linux ¤ËÄɲ䵤줿¡£
299 .BR ppoll ()
300 ¥é¥¤¥Ö¥é¥ê¥³¡¼¥ë¤Ï glibc 2.4 ¤ËÄɲ䵤줿¡£
301 .SH ½àµò
302 .BR poll ()
303 ¤Ï POSIX.1-2001 ¤Ë½àµò¤·¤Æ¤¤¤ë¡£
304 .BR ppoll ()
305 ¤Ï Linux ¸ÇÍ­¤Ç¤¢¤ë¡£
306 .\" NetBSD 3.0 ¤Ë¤Ï pollts() ¤¬¤¢¤ë¡£
307 .\" pollts() ¤Ï Linux ppoll () ¤ÈƱ¤¸¤è¤¦¤Ê¤â¤Î¤Ç¤¢¤ë¡£
308 .SH Ãí°Õ
309 ¤¤¤¯¤Ä¤«¤Î¼ÂÁõ¤Ç¤Ï¡¢ÃÍ \-1 ¤ò»ý¤Ã¤¿Èóɸ½à¤ÎÄê¿ô
310 .B INFTIM
311 ¤¬ÄêµÁ¤µ¤ì¤Æ¤ª¤ê¡¢
312 .I timeout
313 ¤Î»ØÄê¤Ë»ÈÍѤǤ­¤ë¡£
314 ¤³¤ÎÄê¿ô¤Ï glibc ¤Ç¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Ê¤¤¡£
315 .SS "Linux ¤Ç¤ÎÃí°Õ"
316 Linux ¤Î
317 .BR ppoll ()
318 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï
319 .I timeout
320 °ú¤­¿ô¤òÊѹ¹¤¹¤ë¡£
321 ¤·¤«¤·¡¢glibc ¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤Ï¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤ËÅϤ¹ timeout °ú¤­¿ô
322 ¤È¤·¤Æ¥í¡¼¥«¥ëÊÑ¿ô¤ò»È¤¦¤³¤È¤Ç¤³¤ÎÆ°ºî¤ò±£Ê䷤Ƥ¤¤ë¡£
323 ¤³¤Î¤¿¤á¡¢glibc ¤Î
324 .BR ppoll ()
325 ´Ø¿ô¤Ï
326 .I timeout
327 °ú¤­¿ô¤òÊѹ¹¤·¤Ê¤¤¡£
328 .SH ¥Ð¥°
329 .BR select (2)
330 ¤Î¡Ö¥Ð¥°¡×¤ÎÀá¤Ë½ñ¤«¤ì¤Æ¤¤¤ë¡¢¸í¤Ã¤¿½àÈ÷´°Î»ÄÌÃΠ(spurious readiness
331 notifications) ¤Ë¤Ä¤¤¤Æ¤ÎµÄÏÀ¤ò»²¾È¤Î¤³¤È¡£
332 .SH ´ØÏ¢¹àÌÜ
333 .BR select (2),
334 .BR select_tut (2),
335 .BR feature_test_macros (7),
336 .BR time (7)