]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/epoll_ctl.2
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex...
[thirdparty/man-pages.git] / man2 / epoll_ctl.2
CommitLineData
fea681da
MK
1.\"
2.\" epoll by Davide Libenzi ( efficient event notification retrieval )
3.\" Copyright (C) 2003 Davide Libenzi
4.\"
5.\" This program is free software; you can redistribute it and/or modify
6.\" it under the terms of the GNU General Public License as published by
7.\" the Free Software Foundation; either version 2 of the License, or
8.\" (at your option) any later version.
9.\"
10.\" This program is distributed in the hope that it will be useful,
11.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
12.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13.\" GNU General Public License for more details.
14.\"
15.\" You should have received a copy of the GNU General Public License
16.\" along with this program; if not, write to the Free Software
17.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18.\"
19.\" Davide Libenzi <davidel@xmailserver.org>
20.\"
78d1cbde 21.TH EPOLL_CTL 2 2012-04-15 "Linux" "Linux Programmer's Manual"
fea681da
MK
22.SH NAME
23epoll_ctl \- control interface for an epoll descriptor
24.SH SYNOPSIS
25.B #include <sys/epoll.h>
26.sp
52e87bbe
MK
27.BI "int epoll_ctl(int " epfd ", int " op ", int " fd \
28", struct epoll_event *" event );
fea681da 29.SH DESCRIPTION
78d1cbde
MK
30This system call performs control operations on the
31.BR epoll (7)
32instance
a58b3360
MK
33referred to by the file descriptor
34.IR epfd .
35It requests that the operation
0daa9e92 36.I op
7829230a 37be performed for the target file descriptor,
fea681da 38.IR fd .
7829230a
MK
39
40Valid values for the
41.I op
42argument are :
43.TP
44.B EPOLL_CTL_ADD
45Register the target file descriptor
46.I fd
47on the
48.B epoll
49instance referred to by the file descriptor
50.I epfd
51and associate the event
52.I event
53with the internal file linked to
54.IR fd .
55.TP
56.B EPOLL_CTL_MOD
57Change the event
58.I event
59associated with the target file descriptor
60.IR fd .
61.TP
62.B EPOLL_CTL_DEL
63Remove (deregister) the target file descriptor
64.I fd
65from the
66.B epoll
67instance referred to by
68.IR epfd .
69The
70.I event
71is ignored and can be NULL (but see BUGS below).
72.PP
fea681da 73The
0daa9e92 74.I event
7829230a 75argument describes the object linked to the file descriptor
fea681da
MK
76.IR fd .
77The
8478ee02 78.I struct epoll_event
fea681da
MK
79is defined as :
80.sp
a08ea57c 81.in +4n
fea681da 82.nf
cf0a9ace 83typedef union epoll_data {
6ebde978
MK
84 void *ptr;
85 int fd;
2677bc5c
MK
86 uint32_t u32;
87 uint64_t u64;
cf0a9ace 88} epoll_data_t;
fea681da 89
cf0a9ace 90struct epoll_event {
2677bc5c 91 uint32_t events; /* Epoll events */
6ebde978 92 epoll_data_t data; /* User data variable */
cf0a9ace 93};
fea681da 94.fi
a08ea57c 95.in
fea681da
MK
96
97The
98.I events
99member is a bit set composed using the following available event
c781c53c 100types:
fea681da
MK
101.TP
102.B EPOLLIN
103The associated file is available for
104.BR read (2)
105operations.
106.TP
107.B EPOLLOUT
108The associated file is available for
109.BR write (2)
110operations.
111.TP
64d6219c 112.BR EPOLLRDHUP " (since Linux 2.6.17)"
c13182ef 113Stream socket peer closed connection,
04706fd7 114or shut down writing half of connection.
c13182ef 115(This flag is especially useful for writing simple code to detect
04706fd7
MK
116peer shutdown when using Edge Triggered monitoring.)
117.TP
fea681da
MK
118.B EPOLLPRI
119There is urgent data available for
120.BR read (2)
121operations.
122.TP
123.B EPOLLERR
124Error condition happened on the associated file descriptor.
3d9a2200
MK
125.BR epoll_wait (2)
126will always wait for this event; it is not necessary to set it in
127.IR events .
fea681da
MK
128.TP
129.B EPOLLHUP
130Hang up happened on the associated file descriptor.
3d9a2200
MK
131.BR epoll_wait (2)
132will always wait for this event; it is not necessary to set it in
133.IR events .
fea681da
MK
134.TP
135.B EPOLLET
d9bfdb9c
MK
136Sets the Edge Triggered behavior for the associated file descriptor.
137The default behavior for
fea681da 138.B epoll
c13182ef
MK
139is Level Triggered.
140See
2315114c 141.BR epoll (7)
704a18f0 142for more detailed information about Edge and Level Triggered event
fea681da
MK
143distribution architectures.
144.TP
64d6219c 145.BR EPOLLONESHOT " (since Linux 2.6.2)"
d9bfdb9c 146Sets the one-shot behavior for the associated file descriptor.
019934ed 147This means that after an event is pulled out with
fea681da
MK
148.BR epoll_wait (2)
149the associated file descriptor is internally disabled and no other events
150will be reported by the
151.B epoll
c13182ef
MK
152interface.
153The user must call
2777b1ca 154.BR epoll_ctl ()
fea681da
MK
155with
156.B EPOLL_CTL_MOD
3b777aff 157to rearm the file descriptor with a new event mask.
47297adb 158.SH RETURN VALUE
c13182ef 159When successful,
2777b1ca 160.BR epoll_ctl ()
c13182ef
MK
161returns zero.
162When an error occurs,
2777b1ca 163.BR epoll_ctl ()
fea681da
MK
164returns \-1 and
165.I errno
166is set appropriately.
167.SH ERRORS
168.TP
169.B EBADF
fea681da 170.I epfd
2cfa66cf
MK
171or
172.I fd
3d9a2200
MK
173is not a valid file descriptor.
174.TP
175.B EEXIST
176.I op
682edefb
MK
177was
178.BR EPOLL_CTL_ADD ,
179and the supplied file descriptor
0daa9e92 180.I fd
a58b3360 181is already registered with this epoll instance.
fea681da
MK
182.TP
183.B EINVAL
0daa9e92 184.I epfd
fea681da
MK
185is not an
186.B epoll
3d9a2200
MK
187file descriptor,
188or
0daa9e92 189.I fd
3d9a2200
MK
190is the same as
191.IR epfd ,
192or the requested operation
fea681da
MK
193.I op
194is not supported by this interface.
195.TP
3d9a2200
MK
196.B ENOENT
197.I op
682edefb 198was
0daa9e92 199.B EPOLL_CTL_MOD
682edefb
MK
200or
201.BR EPOLL_CTL_DEL ,
202and
0daa9e92 203.I fd