Debian Codegraph @

upstream/debian-unstable/man2/epoll_create.2

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