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  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 call waits for a maximum time of timeout milliseconds.   Specifying
26       a  timeout of -1 makes epoll_wait() wait indefinitely, while specifying
27       a timeout equal to zero makes epoll_wait() to return  immediately  even
28       if no events are available (return code equal to zero).
29
30       The struct epoll_event is defined as :
31
32           typedef union epoll_data {
33               void    *ptr;
34               int      fd;
35               uint32_t u32;
36               uint64_t u64;
37           } epoll_data_t;
38
39           struct epoll_event {
40               uint32_t     events;    /* Epoll events */
41               epoll_data_t data;      /* User data variable */
42           };
43
44       The data of each returned structure will contain the same data the user
45       set with an epoll_ctl(2) (EPOLL_CTL_ADD,EPOLL_CTL_MOD) while the events
46       member will contain the returned event bit field.
47
48   epoll_pwait()
49       The relationship between epoll_wait() and epoll_pwait() is analogous to
50       the relationship between select(2)  and  pselect(2):  like  pselect(2),
51       epoll_pwait()  allows an application to safely wait until either a file
52       descriptor becomes ready or until a signal is caught.
53
54       The following epoll_pwait() call:
55
56           ready = epoll_pwait(epfd, &events, maxevents, timeout, &sigmask);
57
58       is equivalent to atomically executing the following calls:
59
60           sigset_t origmask;
61
62           sigprocmask(SIG_SETMASK, &sigmask, &origmask);
63           ready = epoll_wait(epfd, &events, maxevents, timeout);
64           sigprocmask(SIG_SETMASK, &origmask, NULL);
65
66       The  sigmask  argument  may  be  specified  as  NULL,  in  which   case
67       epoll_pwait() is equivalent to epoll_wait().
68

RETURN VALUE

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

ERRORS

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

VERSIONS

88       epoll_pwait() was added to Linux in kernel 2.6.19.
89
90       Glibc support for epoll_pwait() is provided starting with version 2.6.
91

CONFORMING TO

93       epoll_wait() is Linux-specific, and was introduced in kernel 2.5.44.
94

SEE ALSO

96       epoll_create(2), epoll_ctl(2), epoll(7)
97

COLOPHON

99       This  page  is  part of release 3.22 of the Linux man-pages project.  A
100       description of the project, and information about reporting  bugs,  can
101       be found at http://www.kernel.org/doc/man-pages/.
102
103
104
105Linux                             2009-01-17                     EPOLL_WAIT(2)
Impressum