2 .\" Copyright (c) 2014, Joyent, Inc. All Rights Reserved.
3 .\" This file and its contents are supplied under the terms of the
4 .\" Common Development and Distribution License ("CDDL"), version 1.0.
5 .\" You may only use this file in accordance with the terms of version
8 .\" A full copy of the text of the CDDL should have accompanied this
9 .\" source. A copy of the CDDL is also available via the Internet at
10 .\" http://www.illumos.org/license/CDDL.
11 .TH EPOLL_CTL 3C "April 9, 2016"
13 epoll_ctl \- control an epoll instance
18 #include <sys/epoll.h>
20 \fBint\fR \fBepoll_ctl\fR(\fBint\fR \fIepfd\fR, \fBint\fR \fIop\fR, \fBint\fR \fIfd\fR, \fBstruct epoll_event *\fR\fIevent\fR);
25 The \fBepoll_ctl()\fR function executes the operation specified by
26 \fIop\fR (as parameterized by \fIevent\fR) on the \fIepfd\fR epoll instance.
27 Valid values for \fIop\fR:
35 For the \fBepoll\fR(5) instance specified by \fIepfd\fR,
36 associate the file descriptor specified by \fIfd\fR with the event specified
46 For the \fBepoll\fR(5) instance specified by \fIepfd\fR,
47 remove all event associations for the file descriptor specified by \fIfd\fR.
48 \fIevent\fR is ignored, and may be NULL.
57 For the \fBepoll\fR(5) instance specified by \fIepfd\fR, modify the event
58 association for the file descriptor specified by \fIfd\fR to be that
59 specified by \fIevent\fR.
63 The \fIevent\fR parameter has the following structure:
67 typedef union epoll_data {
81 The \fIdata\fR field specifies the datum to
82 be associated with the event and
83 will be returned via \fBepoll_wait\fR(3C).
84 The \fIevents\fR field denotes both the desired events (when specified via
85 \fBepoll_ctl()\fR) and the events that have occurred (when returned via
86 \fBepoll_wait\fR(3C)).
88 \fIevents\fR field is a bitmask constructed by a logical \fBOR\fR operation
89 of any combination of the following event flags:
97 Data other than high priority data may be read without blocking. For streams,
98 this flag is set in the returned \fIevents\fR even if the message is of
108 Normal data (priority band equals 0) may be read without blocking. For streams,
109 this flag is set in the returned \fIevents\fR even if the message is of zero
119 Normal data (priority band equals 0) may be written without blocking.
128 Normal data (priority band equals 0) may be read without blocking. For streams,
129 this flag is set in the returned \fIrevents\fR even if the message is of
139 Data from a non-zero priority band may be read without blocking. For streams,
140 this flag is set in the returned \fIrevents\fR even if the message is of
150 The same as \fBEPOLLOUT\fR.
159 Priority data (priority band > 0) may be written. This event only examines
160 bands that have been written to at least once.
169 This exists only for backwards binary and source compatibility with Linux;
170 it has no meaning and is ignored.
179 An error has occurred on the device or stream. This flag is only valid in the
180 returned \fIevents\fR field.
189 A hangup has occurred on the stream. This event and \fBEPOLLOUT\fR are mutually
190 exclusive; a stream can never be writable if a hangup has occurred. However,
191 this event and \fBEPOLLIN\fR, \fBEPOLLRDNORM\fR, \fBEPOLLRDBAND\fR,
193 \fBEPOLLPRI\fR are not mutually exclusive. This flag is only valid in the
194 \fIevents\fR field returned from \fBepoll_wait\fR(3C); it is not used in the
195 \fIevents\fR field specified via \fBepoll_ctl()\fR.
204 The stream socket peer shutdown the writing half of the connection and no
205 further data will be readable via the socket. This event is not mutually
206 exclusive with \fBEPOLLIN\fR.
215 This exists only for backwards binary and source compatibility with Linux;
216 it has no meaning and is ignored.
225 Sets the specified event to be in one-shot mode, whereby the event association
226 with the \fBepoll\fR(5) instance specified by \fIepfd\fR is removed atomically
227 as the event is returned via \fBepoll_wait\fR(3C). Use of this mode allows
228 for resolution of some of the
229 races inherent in multithreaded use of \fBepoll_wait\fR(3C).
238 Sets the specified event to be edge-triggered mode instead of the default
239 mode of level-triggered. In this mode, events will be induced by
240 transitions on an event source rather than the state of the event source.
241 While perhaps superficially appealing, this mode introduces several new
242 potential failure modes for user-level software and should be used
248 Upon successful completion, \fBepoll_ctl()\fR returns 0.
249 If an error occurs, -1 is returned and errno is set to indicate
254 \fBepoll_ctl()\fR will fail if:
261 \fIepfd\fR is not a valid file descriptor.
270 The memory associated with \fIevent\fR was not mapped.
279 The operation specified was \fBEPOLL_CTL_ADD\fR and the specified file
280 descriptor is already associated with an event for the specified
281 \fBepoll\fR(5) instance.
290 The operation specified was \fBEPOLL_CTL_MOD\fR or \fBEPOLL_CTL_DEL\fR and
291 the specified file descriptor is not associated with an event for the
292 specified \fBepoll\fR(5) instance.
299 The \fBepoll\fR(5) facility is implemented for purposes of offering
300 compatibility for Linux-borne applications; native
301 applications should continue to prefer using event ports via the
302 \fBport_create\fR(3C), \fBport_associate\fR(3C) and \fBport_get\fR(3C)
303 interfaces. See \fBepoll\fR(5) for compatibility details and restrictions.
307 \fBepoll_create\fR(3C), \fBepoll_wait\fR(3C),
308 \fBport_create\fR(3C), \fBport_associate\fR(3C), \fBport_get\fR(3C),