Manual Pages for Linux CentOS command on man epoll_wait
MyWebUniversity

Manual Pages for Linux CentOS command on man epoll_wait

EPOLLWAIT(2) Linux Programmer's Manual EPOLLWAIT(2)

NAME

epollwait, epollpwait - wait for an I/O event on an epoll file descriptor SYNOPSIS

#include int epollwait(int epfd, struct epollevent *events, int maxevents, int timeout); int epollpwait(int epfd, struct epollevent *events, int maxevents, int timeout, const sigsett *sigmask); DESCRIPTION The epollwait() system call waits for events on the epoll(7) instance referred to by the file descriptor epfd. The memory area pointed to by events will contain the events that will be available for the caller. Up to maxevents are returned by epollwait(). The maxevents argument must be greater than zero. The timeout argument specifies the minimum number of milliseconds that epollwait() will block. (This interval will be rounded up to the sys‐ tem clock granularity, and kernel scheduling delays mean that the blocking interval may overrun by a small amount.) Specifying a timeout

of -1 causes epollwait() to block indefinitely, while specifying a timeout equal to zero cause epollwait() to return immediately, even if no events are available. The struct epollevent is defined as : typedef union epolldata { void *ptr; int fd; uint32t u32; uint64t u64; } epolldatat; struct epollevent { uint32t events; /* Epoll events */ epolldatat data; /* User data variable */ }; The data of each returned structure will contain the same data the user set with an epollctl(2) (EPOLLCTLADD,EPOLLCTLMOD) while the events member will contain the returned event bit field. epollpwait() The relationship between epollwait() and epollpwait() is analogous to the relationship between select(2) and pselect(2): like pselect(2), epollpwait() allows an application to safely wait until either a file descriptor becomes ready or until a signal is caught. The following epollpwait() call: ready = epollpwait(epfd, &events, maxevents, timeout, &sigmask); is equivalent to atomically executing the following calls: sigsett origmask; sigprocmask(SIGSETMASK, &sigmask, &origmask); ready = epollwait(epfd, &events, maxevents, timeout); sigprocmask(SIGSETMASK, &origmask, NULL); The sigmask argument may be specified as NULL, in which case epollpwait() is equivalent to epollwait(). RETURN VALUE When successful, epollwait() returns the number of file descriptors ready for the requested I/O, or zero if no file descriptor became ready during the requested timeout milliseconds. When an error occurs,

epollwait() returns -1 and errno is set appropriately. ERRORS EBADF epfd is not a valid file descriptor. EFAULT The memory area pointed to by events is not accessible with write permissions. EINTR The call was interrupted by a signal handler before either any of the requested events occurred or the timeout expired; see signal(7). EINVAL epfd is not an epoll file descriptor, or maxevents is less than or equal to zero. VERSIONS epollwait() was added to the kernel in version 2.6. Library support is provided in glibc starting with version 2.3.2. epollpwait() was added to Linux in kernel 2.6.19. Library support is provided in glibc starting with version 2.6. CONFORMING TO

epollwait() is Linux-specific. NOTES While one thread is blocked in a call to epollpwait(), it is possible

for another thread to add a file descriptor to the waited-upon epoll instance. If the new file descriptor becomes ready, it will cause the epollwait() call to unblock. For a discussion of what may happen if a file descriptor in an epoll instance being monitored by epollwait() is closed in another thread, see select(2). BUGS In kernels before 2.6.37, a timeout value larger than approximately

LONGMAX / HZ milliseconds is treated as -1 (i.e., infinity). Thus, for example, on a system where the sizeof(long) is 4 and the kernel HZ value is 1000, this means that timeouts greater than 35.79 minutes are treated as infinity. SEE ALSO epollcreate(2), epollctl(2), epoll(7) COLOPHON

This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can

be found at http://www.kernel.org/doc/man-pages/.

Linux 2012-08-17 EPOLLWAIT(2)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™