2 .\" epoll by Davide Libenzi ( efficient event notification retrieval )
3 .\" Copyright (C) 2003 Davide Libenzi
5 .\" This program is free software; you can redistribute it and/or modify
6 .\" it under the terms of the GNU General Public License as published by
7 .\" the Free Software Foundation; either version 2 of the License, or
8 .\" (at your option) any later version.
10 .\" This program is distributed in the hope that it will be useful,
11 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
12 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 .\" GNU General Public License for more details.
15 .\" You should have received a copy of the GNU General Public License
16 .\" along with this program; if not, write to the Free Software
17 .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 .\" Davide Libenzi <davidel@xmailserver.org>
21 .\" 2007-04-30: mtk, Added description of epoll_pwait()
23 .\" Japanese Version Copyright (c) 2004-2005 Yuichi SATO
24 .\" all rights reserved.
25 .\" Translated Wed Jun 16 03:05:40 JST 2004
26 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
27 .\" Updated & Modified Tue Apr 19 07:05:42 JST 2005 by Yuichi SATO
28 .\" Updated 2007-06-02, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v2.51
29 .\" Updated 2009-02-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.18
31 .TH EPOLL_WAIT 2 2009-01-17 "Linux" "Linux Programmer's Manual"
34 .\"O epoll_wait, epoll_pwait \- wait for an I/O event on an epoll file descriptor
35 epoll_wait, epoll_pwait \- epoll ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î I/O ¥¤¥Ù¥ó¥È¤òÂÔ¤Ä
39 .B #include <sys/epoll.h>
41 .BI "int epoll_wait(int " epfd ", struct epoll_event *" events ,
42 .BI " int " maxevents ", int " timeout );
43 .BI "int epoll_pwait(int " epfd ", struct epoll_event *" events ,
44 .BI " int " maxevents ", int " timeout ,
45 .BI " const sigset_t *" sigmask );
50 .\"O .BR epoll_wait ()
51 .\"O system call waits for events on the
53 .\"O instance referred to by the file descriptor
55 .\"O The memory area pointed to by
57 .\"O will contain the events that will be available for the caller.
60 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿
64 ¥¤¥ó¥¹¥¿¥ó¥¹¤ËÂФ¹¤ë¥¤¥Ù¥ó¥È¤òÂԤġ£
66 ¤¬»Ø¤¹¥á¥â¥êÎΰè¤Ë¤Ï¡¢¸Æ¤Ó½Ð¤·Â¦¤¬ÍøÍѲÄǽ¤Ê¥¤¥Ù¥ó¥È¤¬³ÊǼ¤µ¤ì¤ë¡£
70 .\"O .BR epoll_wait ().
78 .\"O argument must be greater than zero.
80 °ú¤¿ô¤Ï 0 ¤è¤êÂ礤¯¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
82 .\"O The call waits for a maximum time of
88 .\"O .BR epoll_wait ()
89 .\"O wait indefinitely, while specifying a
91 .\"O equal to zero makes
92 .\"O .BR epoll_wait ()
93 .\"O to return immediately even if no events are available
94 .\"O (return code equal to zero).
97 ¥ß¥êÉô֥¤¥Ù¥ó¥È¤òÂԤġ£
106 ¤Ï¥¤¥Ù¥ó¥È¤¬ÍøÍѲÄǽ¤Ç¤Ê¤¯¤Æ¤â¡¢¤¹¤°¤ËÊÖ¤ë (ÊÖ¤êÃÍ¤Ï 0 ¤Ç¤¢¤ë)¡£
109 .\"O .I struct epoll_event
111 .I struct epoll_event
112 ¤Ï°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤ë:
116 typedef union epoll_data {
123 .\"O struct epoll_event {
124 .\"O uint32_t events; /* Epoll events */
125 .\"O epoll_data_t data; /* User data variable */
128 uint32_t events; /* epoll ¥¤¥Ù¥ó¥È */
129 epoll_data_t data; /* ¥æ¡¼¥¶¥Ç¡¼¥¿ÊÑ¿ô */
136 .\"O of each returned structure will contain the same data the user set with an
137 .\"O .BR epoll_ctl (2)
138 .\"O .RB ( EPOLL_CTL_ADD , EPOLL_CTL_MOD )
141 .\"O member will contain the returned event bit field.
146 .RB ( EPOLL_CTL_ADD ", " EPOLL_CTL_MOD )
147 ¤Ç»ØÄꤷ¤¿¥Ç¡¼¥¿¤¬³ÊǼ¤µ¤ì¤ë¡£
150 ¥á¥ó¥Ð¤Ë¤ÏÊÖ¤µ¤ì¤¿ÍøÍѲÄǽ¤Ê¥¤¥Ù¥ó¥È¤Î¥Ó¥Ã¥È¥Õ¥£¡¼¥ë¥É¤¬³ÊǼ¤µ¤ì¤ë¡£
152 .\"O The relationship between
153 .\"O .BR epoll_wait ()
155 .\"O .BR epoll_pwait ()
156 .\"O is analogous to the relationship between
159 .\"O .BR pselect (2):
161 .\"O .BR pselect (2),
162 .\"O .BR epoll_pwait ()
163 .\"O allows an application to safely wait until either a file descriptor
164 .\"O becomes ready or until a signal is caught.
176 ¤ò»È¤¦¤È¡¢¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ï¡¢¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬½àÈ÷¤Ç¤¤¿¾õÂ֤ˤʤ뤫¡¢
177 ¥·¥°¥Ê¥ë¤¬Ê᪤µ¤ì¤ë¤Þ¤Ç¡¢°ÂÁ´¤ËÂԤĤ³¤È¤¬¤Ç¤¤ë¡£
180 .\"O .BR epoll_pwait ()
187 ready = epoll_pwait(epfd, &events, maxevents, timeout, &sigmask);
190 .\"O is equivalent to
192 .\"O executing the following calls:
195 ¤Ë¼Â¹Ô¤¹¤ë¤Î¤ÈÅù²Á¤Ç¤¢¤ë¡£
200 sigprocmask(SIG_SETMASK, &sigmask, &origmask);
201 ready = epoll_wait(epfd, &events, maxevents, timeout);
202 sigprocmask(SIG_SETMASK, &origmask, NULL);
207 .\"O argument may be specified as NULL, in which case
208 .\"O .BR epoll_pwait ()
209 .\"O is equivalent to
210 .\"O .BR epoll_wait ().
212 °ú¤¿ô¤Ë¤Ï NULL ¤ò»ØÄꤷ¤Æ¤â¤è¤¤¡£
218 .\"O .SH "RETURN VALUE"
220 .\"O When successful,
221 .\"O .BR epoll_wait ()
222 .\"O returns the number of file descriptors ready for the requested I/O, or zero
223 .\"O if no file descriptor became ready during the requested
226 .\"O When an error occurs,
227 .\"O .BR epoll_wait ()
230 .\"O is set appropriately.
233 ¤ÏÍ׵ᤵ¤ì¤¿ I/O ¤ËÂФ·¤Æ½àÈ÷¤¬¤Ç¤¤Æ¤¤¤ë¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Î¿ô¤òÊÖ¤¹¡£
236 ¥ß¥êÉäδ֤˥ե¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤¬½àÈ÷¤Ç¤¤Ê¤¤¾ì¹ç¤Ï¡¢0 ¤òÊÖ¤¹¡£
237 ¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¾ì¹ç¡¢
247 .\"O is not a valid file descriptor.
249 ¤¬Í¸ú¤Ê¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
252 .\"O The memory area pointed to by
254 .\"O is not accessible with write permissions.
256 ¤Ç»Ø¤µ¤ì¤ë¥á¥â¥êÎΰè¤Ë½ñ¤¹þ¤ß¸¢¸Â¤Ç¥¢¥¯¥»¥¹¤Ç¤¤Ê¤¤¡£
259 .\"O The call was interrupted by a signal handler before any of the
260 .\"O requested events occurred or the
264 Í׵ᤵ¤ì¤¿¤É¤Î¥¤¥Ù¥ó¥È¤âȯÀ¸¤»¤º¡¢¤«¤Ä
266 ¤Î´ü¸Â¤¬ÀÚ¤ì¤ëÁ°¤Ë¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬¥·¥°¥Ê¥ë¥Ï¥ó¥É¥é¤Ë¤è¤Ã¤Æ³ä¤ê¹þ¤Þ¤ì¤¿¡£
274 .\"O file descriptor, or
276 .\"O is less than or equal to zero.
280 ¥Õ¥¡¥¤¥ë¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ç¤Ê¤¤¡£
286 .\"O .BR epoll_pwait ()
287 .\"O was added to Linux in kernel 2.6.19.
289 ¤Ï¥«¡¼¥Í¥ë 2.6.19 ¤Ç Linux ¤ËÄɲ䵤줿¡£
291 .\"O Glibc support for
292 .\"O .BR epoll_pwait ()
293 .\"O is provided starting with glibc 2.6.
295 ¤Î glibc ¤Ç¤Î¥µ¥Ý¡¼¥È¤Ï glibc 2.6 °Ê¹ß¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¡£
296 .\"O .SH CONFORMING TO
298 .\"O .BR epoll_wait ()
299 .\"O is Linux-specific, and was introduced in kernel 2.5.44.
301 ¤Ï Linux Æȼ«¤Ç¤¢¤ê¡¢¥«¡¼¥Í¥ë 2.5.44 ¤ÇƳÆþ¤µ¤ì¤¿¡£
302 .\"O .\" The interface should be finalized by Linux kernel 2.5.66.
303 .\" ¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ï Linux ¥«¡¼¥Í¥ë 2.5.66 ¤Ç³ÎÄꤵ¤ì¤ë¤Ù¤¤Ç¤¢¤ë¡£
306 .BR epoll_create (2),