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 .TH EPOLL_WAIT 2 2009-01-17 "Linux" "Linux Programmer's Manual"
25 epoll_wait, epoll_pwait \- wait for an I/O event on an epoll file descriptor
28 .B #include <sys/epoll.h>
30 .BI "int epoll_wait(int " epfd ", struct epoll_event *" events ,
31 .BI " int " maxevents ", int " timeout );
32 .BI "int epoll_pwait(int " epfd ", struct epoll_event *" events ,
33 .BI " int " maxevents ", int " timeout ,
34 .BI " const sigset_t *" sigmask );
39 system call waits for events on the
41 instance referred to by the file descriptor
43 The memory area pointed to by
45 will contain the events that will be available for the caller.
52 argument must be greater than zero.
54 The call waits for a maximum time of
61 wait indefinitely, while specifying a
65 to return immediately even if no events are available
66 (return code equal to zero).
74 typedef union epoll_data {
82 uint32_t events; /* Epoll events */
83 epoll_data_t data; /* User data variable */
90 of each returned structure will contain the same data the user set with an
92 .RB ( EPOLL_CTL_ADD , EPOLL_CTL_MOD )
95 member will contain the returned event bit field.
97 The relationship between
101 is analogous to the relationship between
108 allows an application to safely wait until either a file descriptor
109 becomes ready or until a signal is caught.
116 ready = epoll_pwait(epfd, &events, maxevents, timeout, &sigmask);
121 executing the following calls:
126 sigprocmask(SIG_SETMASK, &sigmask, &origmask);
127 ready = epoll_wait(epfd, &events, maxevents, timeout);
128 sigprocmask(SIG_SETMASK, &origmask, NULL);
133 argument may be specified as NULL, in which case
140 returns the number of file descriptors ready for the requested I/O, or zero
141 if no file descriptor became ready during the requested
144 When an error occurs,
148 is set appropriately.
153 is not a valid file descriptor.
156 The memory area pointed to by
158 is not accessible with write permissions.
161 The call was interrupted by a signal handler before any of the
162 requested events occurred or the
173 is less than or equal to zero.
176 was added to Linux in kernel 2.6.19.
180 is provided starting with version 2.6.
183 is Linux-specific, and was introduced in kernel 2.5.44.
184 .\" The interface should be finalized by Linux kernel 2.5.66.
186 .BR epoll_create (2),