1EPOLL_CTL(2) Linux Programmer's Manual EPOLL_CTL(2)
2
3
4
6 epoll_ctl - control interface for an epoll descriptor
7
9 #include <sys/epoll.h>
10
11 int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
12
14 Control an epoll descriptor, epfd, by requesting that the operation op
15 be performed on the target file descriptor, fd. The event describes
16 the object linked to the file descriptor fd. The struct epoll_event is
17 defined as :
18
19 typedef union epoll_data {
20 void *ptr;
21 int fd;
22 __uint32_t u32;
23 __uint64_t u64;
24 } epoll_data_t;
25
26 struct epoll_event {
27 __uint32_t events; /* Epoll events */
28 epoll_data_t data; /* User data variable */
29 };
30
31 The events member is a bit set composed using the following available
32 event types :
33
34 EPOLLIN
35 The associated file is available for read(2) operations.
36
37 EPOLLOUT
38 The associated file is available for write(2) operations.
39
40 EPOLLRDHUP (since kernel 2.6.17)
41 Stream socket peer closed connection, or shut down writing half
42 of connection. (This flag is especially useful for writing sim‐
43 ple code to detect peer shutdown when using Edge Triggered moni‐
44 toring.)
45
46 EPOLLPRI
47 There is urgent data available for read(2) operations.
48
49 EPOLLERR
50 Error condition happened on the associated file descriptor.
51 epoll_wait(2) will always wait for this event; it is not neces‐
52 sary to set it in events.
53
54 EPOLLHUP
55 Hang up happened on the associated file descriptor.
56 epoll_wait(2) will always wait for this event; it is not neces‐
57 sary to set it in events.
58
59 EPOLLET
60 Sets the Edge Triggered behaviour for the associated file
61 descriptor. The default behaviour for epoll is Level Triggered.
62 See epoll(7) for more detailed information about Edge and Level
63 Triggered event distribution architectures.
64
65 EPOLLONESHOT (since kernel 2.6.2)
66 Sets the one-shot behaviour for the associated file descriptor.
67 This means that after an event is pulled out with epoll_wait(2)
68 the associated file descriptor is internally disabled and no
69 other events will be reported by the epoll interface. The user
70 must call epoll_ctl(2) with EPOLL_CTL_MOD to re-enable the file
71 descriptor with a new event mask.
72
73 The epoll interface supports all file descriptors that support poll(2).
74 Valid values for the op parameter are :
75
76 EPOLL_CTL_ADD
77 Add the target file descriptor fd to the epoll descriptor
78 epfd and associate the event event with the internal file
79 linked to fd.
80
81 EPOLL_CTL_MOD
82 Change the event event associated with the target file
83 descriptor fd.
84
85 EPOLL_CTL_DEL
86 Remove the target file descriptor fd from the epoll file
87 descriptor, epfd. The event is ignored and can be NULL
88 (but see BUGS below).
89
91 When successful, epoll_ctl(2) returns zero. When an error occurs,
92 epoll_ctl(2) returns -1 and errno is set appropriately.
93
95 EBADF epfd or fd is not a valid file descriptor.
96
97 EEXIST op was EPOLL_CTL_ADD, and the supplied file descriptor fd is
98 already in epfd.
99
100 EINVAL epfd is not an epoll file descriptor, or fd is the same as epfd,
101 or the requested operation op is not supported by this inter‐
102 face.
103
104 ENOENT op was EPOLL_CTL_MOD or EPOLL_CTL_DEL, and fd is not in epfd.
105
106 ENOMEM There was insufficient memory to handle the requested op control
107 operation.
108
109 EPERM The target file fd does not support epoll.
110
112 epoll_ctl(2) is Linux specific, and was introduced in kernel 2.5.44.
113
115 In kernel versions before 2.6.9, the EPOLL_CTL_DEL operation required a
116 non-NULL pointer in event, even though this argument is ignored. Since
117 kernel 2.6.9, event can be specified as NULL when using EPOLL_CTL_DEL.
118
120 epoll_create(2), epoll_wait(2), poll(2), epoll(7)
121
122
123
124Linux 2002-10-23 EPOLL_CTL(2)