]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/epoll_create.2
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man2 / epoll_create.2
CommitLineData
fea681da 1.\" Copyright (C) 2003 Davide Libenzi
962a269d 2.\" and Copyright 2008, 2009, 2012 Michael Kerrisk <tk.manpages@gmail.com>
4366109b 3.\" Davide Libenzi <davidel@xmailserver.org>
fea681da 4.\"
e4a74ca8 5.\" SPDX-License-Identifier: GPL-2.0-or-later
fea681da 6.\"
c11b1abf 7.\" Modified 2004-06-17 by Michael Kerrisk <mtk.manpages@gmail.com>
3d9a2200 8.\" Modified 2005-04-04 by Marko Kohtala <marko.kohtala@gmail.com>
272fa3cb 9.\" 2008-10-10, mtk: add description of epoll_create1()
fea681da 10.\"
4c1c5274 11.TH epoll_create 2 (date) "Linux man-pages (unreleased)"
fea681da 12.SH NAME
272fa3cb 13epoll_create, epoll_create1 \- open an epoll file descriptor
ee5c804b
AC
14.SH LIBRARY
15Standard C library
8fc3b2cf 16.RI ( libc ", " \-lc )
fea681da 17.SH SYNOPSIS
272fa3cb 18.nf
fea681da 19.B #include <sys/epoll.h>
68e4db0a 20.PP
52e87bbe 21.BI "int epoll_create(int " size );
272fa3cb
MK
22.BI "int epoll_create1(int " flags );
23.fi
fea681da 24.SH DESCRIPTION
272fa3cb 25.BR epoll_create ()
65c031fb 26creates a new
5f4e9d5a 27.BR epoll (7)
fde633de
MK
28instance.
29Since Linux 2.6.8, the
272fa3cb 30.I size
cce4f974 31argument is ignored, but must be greater than zero; see NOTES.
efeece04 32.PP
700e0efd
MK
33.BR epoll_create ()
34returns a file descriptor referring to the new epoll instance.
35This file descriptor is used for all the subsequent calls to the
fea681da 36.B epoll
c13182ef 37interface.
700e0efd 38When no longer required, the file descriptor returned by
2777b1ca 39.BR epoll_create ()
700e0efd 40should be closed by using
fea681da 41.BR close (2).
700e0efd
MK
42When all file descriptors referring to an epoll instance have been closed,
43the kernel destroys the instance
3b777aff 44and releases the associated resources for reuse.
6b6f5404 45.SS epoll_create1()
272fa3cb
MK
46If
47.I flags
48is 0, then, other than the fact that the obsolete
e1fbfba5 49.I size
272fa3cb
MK
50argument is dropped,
51.BR epoll_create1 ()
52is the same as
53.BR epoll_create ().
54The following value can be included in
1ae6b2c7 55.I flags
272fa3cb
MK
56to obtain different behavior:
57.TP
58.B EPOLL_CLOEXEC
59Set the close-on-exec
9c9cccf7 60.RB ( FD_CLOEXEC )
272fa3cb 61flag on the new file descriptor.
c5571b61 62See the description of the
272fa3cb
MK
63.B O_CLOEXEC
64flag in
65.BR open (2)
66for reasons why this may be useful.
47297adb 67.SH RETURN VALUE
c5571b61 68On success,
272fa3cb 69these system calls
ed09120a 70return a file descriptor (a nonnegative integer).
272fa3cb 71On error, \-1 is returned, and
fea681da 72.I errno
272fa3cb 73is set to indicate the error.
fea681da
MK
74.SH ERRORS
75.TP
3d9a2200
MK
76.B EINVAL
77.I size
78is not positive.
79.TP
272fa3cb
MK
80.B EINVAL
81.RB ( epoll_create1 ())
82Invalid value specified in
83.IR flags .
84.TP
1c7a3214
MK
85.B EMFILE
86The per-user limit on the number of epoll instances imposed by
87.I /proc/sys/fs/epoll/max_user_instances
88was encountered.
89See
90.BR epoll (7)
91for further details.
92.TP
6bde54af
MK
93.B EMFILE
94The per-process limit on the number of open file descriptors has been reached.
95.TP
fea681da 96.B ENFILE
e258766b 97The system-wide limit on the total number of open files has been reached.
fea681da
MK
98.TP
99.B ENOMEM
100There was insufficient memory to create the kernel object.
6c3529d8 101.SH VERSIONS
2777b1ca 102.BR epoll_create ()
6c3529d8
MK
103was added to the kernel in version 2.6.
104Library support is provided in glibc starting with version 2.3.2.
efeece04 105.PP
6c3529d8 106.\" To be precise: kernel 2.5.44.
75b48e9d 107.\" The interface should be finalized by Linux kernel 2.5.66.
6c3529d8
MK
108.BR epoll_create1 ()
109was added to the kernel in version 2.6.27.
110Library support is provided in glibc starting with version 2.9.
3113c7f3 111.SH STANDARDS
6c3529d8 112.BR epoll_create ()
e4c07f64
MK
113and
114.BR epoll_create1 ()
115are Linux-specific.
9967820f 116.SH NOTES
fde633de
MK
117In the initial
118.BR epoll_create ()
119implementation, the
120.I size
121argument informed the kernel of the number of file descriptors
122that the caller expected to add to the
123.B epoll
124instance.
125The kernel used this information as a hint for the amount of
126space to initially allocate in internal data structures describing events.
127(If necessary, the kernel would allocate more space
128if the caller's usage exceeded the hint given in
129.IR size .)
130Nowadays,
131this hint is no longer required
132(the kernel dynamically sizes the required data structures
133without needing the hint), but
9967820f 134.I size
fde633de
MK
135must still be greater than zero,
136in order to ensure backward compatibility when new
137.B epoll
138applications are run on older kernels.
47297adb 139.SH SEE ALSO
fea681da
MK
140.BR close (2),
141.BR epoll_ctl (2),
142.BR epoll_wait (2),
2315114c 143.BR epoll (7)