man-pages/man2/epoll_create.2.html
2021-03-31 01:06:50 +01:00

242 lines
5.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of EPOLL_CREATE</TITLE>
</HEAD><BODY>
<H1>EPOLL_CREATE</H1>
Section: Linux Programmer's Manual (2)<BR>Updated: 2017-09-15<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
epoll_create, epoll_create1 - open an epoll file descriptor
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
<B>#include &lt;<A HREF="file:///usr/include/sys/epoll.h">sys/epoll.h</A>&gt;</B>
<B>int epoll_create(int </B><I>size</I><B>);</B>
<B>int epoll_create1(int </B><I>flags</I><B>);</B>
</PRE>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<B>epoll_create</B>()
creates a new
<B><A HREF="/cgi-bin/man/man2html?7+epoll">epoll</A></B>(7)
instance.
Since Linux 2.6.8, the
<I>size</I>
argument is ignored, but must be greater than zero; see NOTES below.
<P>
<B>epoll_create</B>()
returns a file descriptor referring to the new epoll instance.
This file descriptor is used for all the subsequent calls to the
<B>epoll</B>
interface.
When no longer required, the file descriptor returned by
<B>epoll_create</B>()
should be closed by using
<B><A HREF="/cgi-bin/man/man2html?2+close">close</A></B>(2).
When all file descriptors referring to an epoll instance have been closed,
the kernel destroys the instance
and releases the associated resources for reuse.
<A NAME="lbAE">&nbsp;</A>
<H3>epoll_create1()</H3>
If
<I>flags</I>
is 0, then, other than the fact that the obsolete
<I>size</I>
argument is dropped,
<B>epoll_create1</B>()
is the same as
<B>epoll_create</B>().
The following value can be included in
<I>flags</I>
to obtain different behavior:
<DL COMPACT>
<DT id="1"><B>EPOLL_CLOEXEC</B>
<DD>
Set the close-on-exec
(<B>FD_CLOEXEC</B>)
flag on the new file descriptor.
See the description of the
<B>O_CLOEXEC</B>
flag in
<B><A HREF="/cgi-bin/man/man2html?2+open">open</A></B>(2)
for reasons why this may be useful.
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>RETURN VALUE</H2>
On success,
these system calls
return a nonnegative file descriptor.
On error, -1 is returned, and
<I>errno</I>
is set to indicate the error.
<A NAME="lbAG">&nbsp;</A>
<H2>ERRORS</H2>
<DL COMPACT>
<DT id="2"><B>EINVAL</B>
<DD>
<I>size</I>
is not positive.
<DT id="3"><B>EINVAL</B>
<DD>
(<B>epoll_create1</B>())
Invalid value specified in
<I>flags</I>.
<DT id="4"><B>EMFILE</B>
<DD>
The per-user limit on the number of epoll instances imposed by
<I>/proc/sys/fs/epoll/max_user_instances</I>
was encountered.
See
<B><A HREF="/cgi-bin/man/man2html?7+epoll">epoll</A></B>(7)
for further details.
<DT id="5"><B>EMFILE</B>
<DD>
The per-process limit on the number of open file descriptors has been reached.
<DT id="6"><B>ENFILE</B>
<DD>
The system-wide limit on the total number of open files has been reached.
<DT id="7"><B>ENOMEM</B>
<DD>
There was insufficient memory to create the kernel object.
</DL>
<A NAME="lbAH">&nbsp;</A>
<H2>VERSIONS</H2>
<B>epoll_create</B>()
was added to the kernel in version 2.6.
Library support is provided in glibc starting with version 2.3.2.
<P>
<B>epoll_create1</B>()
was added to the kernel in version 2.6.27.
Library support is provided in glibc starting with version 2.9.
<A NAME="lbAI">&nbsp;</A>
<H2>CONFORMING TO</H2>
<B>epoll_create</B>()
is Linux-specific.
<A NAME="lbAJ">&nbsp;</A>
<H2>NOTES</H2>
In the initial
<B>epoll_create</B>()
implementation, the
<I>size</I>
argument informed the kernel of the number of file descriptors
that the caller expected to add to the
<B>epoll</B>
instance.
The kernel used this information as a hint for the amount of
space to initially allocate in internal data structures describing events.
(If necessary, the kernel would allocate more space
if the caller's usage exceeded the hint given in
<I>size</I>.)
Nowadays,
this hint is no longer required
(the kernel dynamically sizes the required data structures
without needing the hint), but
<I>size</I>
must still be greater than zero,
in order to ensure backward compatibility when new
<B>epoll</B>
applications are run on older kernels.
<A NAME="lbAK">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?2+close">close</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+epoll_ctl">epoll_ctl</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?2+epoll_wait">epoll_wait</A></B>(2),
<B><A HREF="/cgi-bin/man/man2html?7+epoll">epoll</A></B>(7)
<A NAME="lbAL">&nbsp;</A>
<H2>COLOPHON</H2>
This page is part of release 5.05 of the Linux
<I>man-pages</I>
project.
A description of the project,
information about reporting bugs,
and the latest version of this page,
can be found at
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="8"><A HREF="#lbAB">NAME</A><DD>
<DT id="9"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="10"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DL>
<DT id="11"><A HREF="#lbAE">epoll_create1()</A><DD>
</DL>
<DT id="12"><A HREF="#lbAF">RETURN VALUE</A><DD>
<DT id="13"><A HREF="#lbAG">ERRORS</A><DD>
<DT id="14"><A HREF="#lbAH">VERSIONS</A><DD>
<DT id="15"><A HREF="#lbAI">CONFORMING TO</A><DD>
<DT id="16"><A HREF="#lbAJ">NOTES</A><DD>
<DT id="17"><A HREF="#lbAK">SEE ALSO</A><DD>
<DT id="18"><A HREF="#lbAL">COLOPHON</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:32 GMT, March 31, 2021
</BODY>
</HTML>