1EPOLL_WAIT(2)              Linux Programmer's Manual             EPOLL_WAIT(2)
2
3
4

NAME

6       epoll_wait,  epoll_pwait  -  wait  for  an  I/O  event on an epoll file
7       descriptor
8

SYNOPSIS

10       #include <sys/epoll.h>
11
12       int epoll_wait(int epfd, struct epoll_event *events,
13                      int maxevents, int timeout);
14       int epoll_pwait(int epfd, struct epoll_event *events,
15                      int maxevents, int timeout,
16                      const sigset_t *sigmask);
17

DESCRIPTION

19       The epoll_wait() system call waits for events on the epoll(7)  instance
20       referred to by the file descriptor epfd.  The memory area pointed to by
21       events will contain the events that will be available for  the  caller.
22       Up  to  maxevents are returned by epoll_wait().  The maxevents argument
23       must be greater than zero.
24
25       The timeout argument specifies the minimum number of milliseconds  that
26       epoll_wait() will block.  (This interval will be rounded up to the sys‐
27       tem clock granularity, and  kernel  scheduling  delays  mean  that  the
28       blocking interval may overrun by a small amount.)  Specifying a timeout
29       of -1 causes epoll_wait() to block  indefinitely,  while  specifying  a
30       timeout equal to zero cause epoll_wait() to return immediately, even if
31       no events are available.
32
33       The struct epoll_event is defined as :
34
35           typedef union epoll_data {
36               void    *ptr;
37               int      fd;
38               uint32_t u32;
39               uint64_t u64;
40           } epoll_data_t;
41
42           struct epoll_event {
43               uint32_t     events;    /* Epoll events */
44               epoll_data_t data;      /* User data variable */
45           };
46
47       The data of each returned structure will contain the same data the user
48       set with an epoll_ctl(2) (EPOLL_CTL_ADD,EPOLL_CTL_MOD) while the events
49       member will contain the returned event bit field.
50
51   epoll_pwait()
52       The relationship between epoll_wait() and epoll_pwait() is analogous to
53       the  relationship  between  select(2)  and pselect(2): like pselect(2),
54       epoll_pwait() allows an application to safely wait until either a  file
55       descriptor becomes ready or until a signal is caught.
56
57       The following epoll_pwait() call:
58
59           ready = epoll_pwait(epfd, &events, maxevents, timeout, &sigmask);
60
61       is equivalent to atomically executing the following calls:
62
63           sigset_t origmask;
64
65           sigprocmask(SIG_SETMASK, &sigmask, &origmask);
66           ready = epoll_wait(epfd, &events, maxevents, timeout);
67           sigprocmask(SIG_SETMASK, &origmask, NULL);
68
69       The   sigmask  argument  may  be  specified  as  NULL,  in  which  case
70       epoll_pwait() is equivalent to epoll_wait().
71

RETURN VALUE

73       When successful, epoll_wait() returns the number  of  file  descriptors
74       ready for the requested I/O, or zero if no file descriptor became ready
75       during the requested  timeout  milliseconds.   When  an  error  occurs,
76       epoll_wait() returns -1 and errno is set appropriately.
77

ERRORS

79       EBADF  epfd is not a valid file descriptor.
80
81       EFAULT The  memory  area  pointed  to  by events is not accessible with
82              write permissions.
83
84       EINTR  The call was interrupted by a signal handler before  either  any
85              of  the  requested  events  occurred or the timeout expired; see
86              signal(7).
87
88       EINVAL epfd is not an epoll file descriptor, or maxevents is less  than
89              or equal to zero.
90

VERSIONS

92       epoll_wait()  was  added to the kernel in version 2.6.  Library support
93       is provided in glibc starting with version 2.3.2.
94
95       epoll_pwait() was added to Linux in kernel 2.6.19.  Library support  is
96       provided in glibc starting with version 2.6.
97

CONFORMING TO

99       epoll_wait() is Linux-specific.
100

NOTES

102       While  one thread is blocked in a call to epoll_pwait(), it is possible
103       for another thread to add a file descriptor to  the  waited-upon  epoll
104       instance.   If the new file descriptor becomes ready, it will cause the
105       epoll_wait() call to unblock.
106
107       For a discussion of what may happen if a file descriptor  in  an  epoll
108       instance  being  monitored by epoll_wait() is closed in another thread,
109       see select(2).
110

BUGS

112       In kernels before 2.6.37, a timeout  value  larger  than  approximately
113       LONG_MAX  /  HZ  milliseconds is treated as -1 (i.e., infinity).  Thus,
114       for example, on a system where the sizeof(long) is 4 and the kernel  HZ
115       value  is 1000, this means that timeouts greater than 35.79 minutes are
116       treated as infinity.
117

SEE ALSO

119       epoll_create(2), epoll_ctl(2), epoll(7)
120

COLOPHON

122       This page is part of release 3.53 of the Linux  man-pages  project.   A
123       description  of  the project, and information about reporting bugs, can
124       be found at http://www.kernel.org/doc/man-pages/.
125
126
127
128Linux                             2012-08-17                     EPOLL_WAIT(2)
Impressum