1 .\" Copyright (C) 2003 Davide Libenzi
2 .\" Davide Libenzi <davidel@xmailserver.org>
4 .\" %%%LICENSE_START(GPLv2+_SW_3_PARA)
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
16 .\" License along with this manual; if not, see
17 .\" <http://www.gnu.org/licenses/>.
20 .\" 2007-04-30: mtk, Added description of epoll_pwait()
22 .TH EPOLL_WAIT 2 2014-01-31 "Linux" "Linux Programmer's Manual"
24 epoll_wait, epoll_pwait \- wait for an I/O event on an epoll file descriptor
27 .B #include <sys/epoll.h>
29 .BI "int epoll_wait(int " epfd ", struct epoll_event *" events ,
30 .BI " int " maxevents ", int " timeout );
31 .BI "int epoll_pwait(int " epfd ", struct epoll_event *" events ,
32 .BI " int " maxevents ", int " timeout ,
33 .BI " const sigset_t *" sigmask );
38 system call waits for events on the
40 instance referred to by the file descriptor
42 The memory area pointed to by
44 will contain the events that will be available for the caller.
51 argument must be greater than zero.
55 argument specifies the number of milliseconds that
58 The call will block until either:
60 a file descriptor delivers an event;
62 the call is interrupted by a signal handler; or
68 interval will be rounded up to the system clock granularity,
69 and kernel scheduling delays mean that the blocking interval
70 may overrun by a small amount.
75 to block indefinitely, while specifying a
79 to return immediately, even if no events are available.
87 typedef union epoll_data {
95 uint32_t events; /* Epoll events */
96 epoll_data_t data; /* User data variable */
103 of each returned structure will contain the same data the user set with an
105 .RB ( EPOLL_CTL_ADD ", " EPOLL_CTL_MOD )
108 member will contain the returned event bit field.
110 The relationship between
114 is analogous to the relationship between
121 allows an application to safely wait until either a file descriptor
122 becomes ready or until a signal is caught.
129 ready = epoll_pwait(epfd, &events, maxevents, timeout, &sigmask);
134 executing the following calls:
139 sigprocmask(SIG_SETMASK, &sigmask, &origmask);
140 ready = epoll_wait(epfd, &events, maxevents, timeout);
141 sigprocmask(SIG_SETMASK, &origmask, NULL);
146 argument may be specified as NULL, in which case
153 returns the number of file descriptors ready for the requested I/O, or zero
154 if no file descriptor became ready during the requested
157 When an error occurs,
161 is set appropriately.
166 is not a valid file descriptor.
169 The memory area pointed to by
171 is not accessible with write permissions.
174 The call was interrupted by a signal handler before either (1) any of the
175 requested events occurred or (2) the
186 is less than or equal to zero.
189 was added to the kernel in version 2.6.
190 .\" To be precise: kernel 2.5.44.
191 .\" The interface should be finalized by Linux kernel 2.5.66.
192 Library support is provided in glibc starting with version 2.3.2.
195 was added to Linux in kernel 2.6.19.
196 Library support is provided in glibc starting with version 2.6.
201 While one thread is blocked in a call to
203 it is possible for another thread to add a file descriptor to the waited-upon
206 If the new file descriptor becomes ready,
211 For a discussion of what may happen if a file descriptor in an
213 instance being monitored by
215 is closed in another thread, see
218 In kernels before 2.6.37, a
220 value larger than approximately
222 milliseconds is treated as \-1 (i.e., infinity).
223 Thus, for example, on a system where the
228 this means that timeouts greater than 35.79 minutes are treated as infinity.
230 .BR epoll_create (2),
234 This page is part of release 3.68 of the Linux
237 A description of the project,
238 information about reporting bugs,
239 and the latest version of this page,
241 \%http://www.kernel.org/doc/man\-pages/.