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