EPOLL_CTL(3C) | Standard C Library Functions | EPOLL_CTL(3C) |
epoll_ctl - control an epoll instance
#include <sys/epoll.h> int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
The epoll_ctl() function executes the operation specified by op (as parameterized by event) on the epfd epoll instance. Valid values for op:
EPOLL_CTL_ADD
EPOLL_CTL_DEL
EPOLL_CTL_MOD
The event parameter has the following structure:
typedef union epoll_data { void *ptr; int fd; uint32_t u32; uint64_t u64; } epoll_data_t; struct epoll_event { uint32_t events; epoll_data_t data; };
The data field specifies the datum to be associated with the event and will be returned via epoll_wait(3C). The events field denotes both the desired events (when specified via epoll_ctl()) and the events that have occurred (when returned via epoll_wait(3C)). In either case, the events field is a bitmask constructed by a logical OR operation of any combination of the following event flags:
EPOLLIN
EPOLLPRI
EPOLLOUT
EPOLLRDNORM
EPOLLRDBAND
EPOLLWRNORM
EPOLLWRBAND
EPOLLMSG
EPOLLERR
EPOLLHUP
EPOLLRDHUP
EPOLLEXCLUSIVE
The flag was added to Linux in v4.5 to provide a means to mitigate thundering herd problems when multiple epoll instances contain the same event source. Set on a specified event source during EPOLL_CTL_ADD (and not allowed with EPOLL_CTL_MOD), it indicates that epoll should attempt to limit the scope of pollers woken when a shared target resource changes state. All pollers without the flag set in the event will be notified and one or more of those with it set will be as well.
EPOLLWAKEUP
EPOLLONESHOT
EPOLLET
Upon successful completion, epoll_ctl() returns 0. If an error occurs, -1 is returned and errno is set to indicate the error.
epoll_ctl() will fail if:
EBADF
EFAULT
EEXIST
ENOENT
The epoll(7) facility is implemented for purposes of offering compatibility for Linux-borne applications; native applications should continue to prefer using event ports via the port_create(3C), port_associate(3C) and port_get(3C) interfaces. See epoll(7) for compatibility details and restrictions.
epoll_create(3C), epoll_wait(3C), port_associate(3C), port_create(3C), port_get(3C), epoll(7)
June 29, 2020 | OmniOS |