epoll_ctl(2) System Calls Manual epoll_ctl(2) epoll_ctl - epoll LIBRARY Standard C library (libc, -lc) #include int epoll_ctl(int epfd, int op, int fd, struct epoll_event *_Nullable event); , , interest epoll(7), epfd. op fd. op: EPOLL_CTL_ADD Add an entry to the interest list of the epoll file descriptor, epfd. The entry includes the file descriptor, fd, a reference to the corresponding open file description (see epoll(7) and open(2)), and the settings specified in event. EPOLL_CTL_MOD , fd interest, , event. EPOLL_CTL_DEL ( ) fd interest. event NULL ( ). The event argument describes the object linked to the file descriptor fd. The struct epoll_event is described in epoll_event(3type). The data member of the epoll_event structure specifies data that the kernel should save and then return (via epoll_wait(2)) when this file descriptor becomes ready. The events member of the epoll_event structure is a bit mask composed by ORing together zero or more event types, returned by epoll_wait(2), and input flags, which affect its behaviour, but aren't returned. The available event types are: EPOLLIN read(2). EPOLLOUT write(2). EPOLLRDHUP ( Linux 2.6.17) ( edge-triggered). EPOLLPRI . POLLPRI poll(2). EPOLLERR . , . epoll_wait(2) will always report for this event; it is not necessary to set it in events when calling epoll_ctl(). EPOLLHUP Hang up happened on the associated file descriptor. epoll_wait(2) will always wait for this event; it is not necessary to set it in events when calling epoll_ctl(). , , (pipe) , - , . 0 ( ) . And the available input flags are: EPOLLET Requests edge-triggered notification for the associated file descriptor. The default behavior for epoll is level-triggered. See epoll(7) for more detailed information about edge-triggered and level-triggered notification. EPOLLONESHOT ( Linux 2.6.2) Requests one-shot notification for the associated file descriptor. This means that after an event notified for the file descriptor by epoll_wait(2), the file descriptor is disabled in the interest list and no other events will be reported by the epoll interface. The user must call epoll_ctl() with EPOLL_CTL_MOD to rearm the file descriptor with a new event mask. EPOLLWAKEUP ( Linux 3.5) EPOLLONESHOT EPOLLET CAP_BLOCK_SUSPEND, , <> <>, . <<>> , epoll_wait(2) epoll_wait(2) epoll(7), , EPOLL_CTL_DEL EPOLLWAKEUP EPOLL_CTL_MOD. . EPOLLEXCLUSIVE ( Linux 4.5) epoll, fd. epoll EPOLLEXCLUSIVE, epoll epoll_wait(2). ( EPOLLEXCLUSIVE ) epoll . EPOLLEXCLUSIVE . epoll, EPOLLEXCLUSIVE, , epoll, EPOLLEXCLUSIVE, , , epoll, EPOLLEXCLUSIVE. EPOLLEXCLUSIVE: EPOLLIN, EPOLLOUT, EPOLLWAKEUP EPOLLET. EPOLLHUP EPOLLERR, : , , , events. events EINVAL. EPOLLEXCLUSIVE EPOLL_CTL_ADD; EPOLL_CTL_MOD . EPOLLEXCLUSIVE epoll_ctl(), EPOLL_CTL_MOD epfd, fd . epoll_ctl(), EPOLLEXCLUSIVE events fd epoll, . EINVAL. When successful, epoll_ctl() returns zero. When an error occurs, epoll_ctl() returns -1 and errno is set to indicate the error. EBADF epfd fd . EEXIST op EPOLL_CTL_ADD, fd epoll. EINVAL epfd epoll, fd epfd, op . EINVAL , events EPOLLEXCLUSIVE. EINVAL op EPOLL_CTL_MOD events EPOLLEXCLUSIVE. EINVAL op EPOLL_CTL_MOD, epfd, fd EPOLLEXCLUSIVE. EINVAL EPOLLEXCLUSIVE event fd epoll. ELOOP fd refers to an epoll instance and this EPOLL_CTL_ADD operation would result in a circular loop of epoll instances monitoring one another or a nesting depth of epoll instances greater than 5. ENOENT op EPOLL_CTL_MOD EPOLL_CTL_DEL, fd epoll. ENOMEM op. ENOSPC (EPOLL_CTL_ADD) , /proc/sys/fs/epoll/max_user_watches. . epoll(7). EPERM fd epoll. , fd , , . Linux. Linux 2.6, glibc 2.3.2. epoll , poll(2). Before Linux 2.6.9, the EPOLL_CTL_DEL operation required a non-null pointer in event, even though this argument is ignored. Since Linux 2.6.9, event can be specified as NULL when using EPOLL_CTL_DEL. Applications that need to be portable to kernels before Linux 2.6.9 should specify a non-null pointer in event. flags EPOLLWAKEUP, CAP_BLOCK_SUSPEND, EPOLLWAKEUP . , flags, EPOLLWAKEUP , , CAP_BLOCK_SUSPEND, , ( ) . , CAP_BLOCK_SUSPEND, EPOLLWAKEUP. . epoll_create(2), epoll_wait(2), poll(2), epoll(7) Azamat Hackimov , Yuri Kozlov ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . epoll_ctl(2)