OSDN Git Service

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