OSDN Git Service

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