nightly: remove unused BINARCHIVE
[unleashed.git] / share / man / man3c / epoll_ctl.3c
blob4d63d084f9f22c1541ade5d3ba63a519969d07a0
1 '\" te
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
6 .\"  1.0 of the CDDL.
7 .\"
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"
12 .SH NAME
13 epoll_ctl \- control an epoll instance
14 .SH SYNOPSIS
16 .LP
17 .nf
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);
21 .fi
23 .SH DESCRIPTION
24 .LP
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:
29 .sp
30 .ne 2
31 .na
32 \fBEPOLL_CTL_ADD\fR
33 .ad
34 .RS 12n
35 For the \fBepoll\fR(5) instance specified by \fIepfd\fR,
36 associate the file descriptor specified by \fIfd\fR with the event specified
37 by \fIevent\fR.
38 .RE
40 .sp
41 .ne 2
42 .na
43 \fBEPOLL_CTL_DEL\fR
44 .ad
45 .RS 12n
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.
49 .RE
51 .sp
52 .ne 2
53 .na
54 \fBEPOLL_CTL_MOD\fR
55 .ad
56 .RS 12n
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.
61 .RE
63 The \fIevent\fR parameter has the following structure:
65 .in +4
66 .nf
67 typedef union epoll_data {
68         void    *ptr;
69         int      fd;
70         uint32_t u32;
71         uint64_t u64;
72 } epoll_data_t;
74 struct epoll_event {
75         uint32_t     events;
76         epoll_data_t data;
78 .fi
79 .in -4
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)).
87 In either case, the
88 \fIevents\fR field is a bitmask constructed by a logical \fBOR\fR operation
89 of any combination of the following event flags:
91 .sp
92 .ne 2
93 .na
94 \fBEPOLLIN\fR
95 .ad
96 .RS 14n
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
99 zero length.
103 .ne 2
105 \fBEPOLLPRI\fR
107 .RS 14n
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
110 length.
114 .ne 2
116 \fBEPOLLOUT\fR
118 .RS 14n
119 Normal data (priority band equals 0) may be written without blocking.
123 .ne 2
125 \fBEPOLLRDNORM\fR
127 .RS 14n
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
130 zero length.
134 .ne 2
136 \fBEPOLLRDBAND\fR
138 .RS 14n
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
141 zero length.
145 .ne 2
147 \fBEPOLLWRNORM\fR
149 .RS 14n
150 The same as \fBEPOLLOUT\fR.
154 .ne 2
156 \fBEPOLLWRBAND\fR
158 .RS 14n
159 Priority data (priority band > 0) may be written.  This event only examines
160 bands that have been written to at least once.
164 .ne 2
166 \fBEPOLLMSG\fR
168 .RS 14n
169 This exists only for backwards binary and source compatibility with Linux;
170 it has no meaning and is ignored.
174 .ne 2
176 \fBEPOLLERR\fR
178 .RS 14n
179 An error has occurred on the device or stream.  This flag is only valid in the
180 returned \fIevents\fR field.
184 .ne 2
186 \fBEPOLLHUP\fR
188 .RS 14n
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,
192 \fBEPOLLRDHUP\fR or
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.
199 .ne 2
201 \fBEPOLLRDHUP\fR
203 .RS 14n
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.
210 .ne 2
212 \fBEPOLLWAKEUP\fR
214 .RS 14n
215 This exists only for backwards binary and source compatibility with Linux;
216 it has no meaning and is ignored.
220 .ne 2
222 \fBEPOLLONESHOT\fR
224 .RS 14n
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).
233 .ne 2
235 \fBEPOLLET\fR
237 .RS 14n
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
243 with caution.
246 .SH RETURN VALUES
248 Upon successful completion, \fBepoll_ctl()\fR returns 0.
249 If an error occurs, -1 is returned and errno is set to indicate
250 the error.
252 .SH ERRORS
254 \fBepoll_ctl()\fR will fail if:
256 .ne 2
258 \fB\fBEBADF\fR\fR
260 .RS 10n
261 \fIepfd\fR is not a valid file descriptor.
265 .ne 2
267 \fB\fBEFAULT\fR\fR
269 .RS 10n
270 The memory associated with \fIevent\fR was not mapped.
274 .ne 2
276 \fB\fBEEXIST\fR\fR
278 .RS 10n
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.
285 .ne 2
287 \fB\fBENOENT\fR\fR
289 .RS 10n
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.
296 .SH NOTES
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.
305 .SH SEE ALSO
307 \fBepoll_create\fR(3C), \fBepoll_wait\fR(3C),
308 \fBport_create\fR(3C), \fBport_associate\fR(3C), \fBport_get\fR(3C),
309 \fBepoll\fR(5)