名字
epoll_create, epoll_create1 - open an epoll file descriptor
梗概
#include <sys/epoll.h>
int epoll_create(int size);
int epoll_create1(int flags);
描述:
epoll_create() creates an epoll(7) instance(实例). Linux 2.6.8 及以后的版本size参数被忽略, 但是必须大于0;看下面的’注意’.
epoll_create() 返回一个新epoll实例相关的文件描述符,这个文件描述符用在所有随后的函数调用,不在使用的时候,文件描述符应用close()关闭,所有文件描述符关闭的时候(意思是引用计数减到0时),内核将销毁实例并释放相关资源。epoll_create1()
If flags is 0, then, other than the fact that the obsolete(废弃的) size argument is dropped, epoll_create1() is the same as epoll_create(). flag取下面的值可以用来获取不同的行为:
EPOLL_CLOEXEC
- Set the close-on-exec (FD_CLOEXEC) flag on the new file descriptor. See the description of the O_CLOEXEC flag in open(2) for reasons why this may be useful.
RETURN VALUE
- 成功返回一个非负的描述符,失败返回-1,同时errno被设置
- ERRORS
- EINVAL size is not positive.
- EINVAL (epoll_create1()) Invalid(无效) value specified in flags.
- EMFILE The per-user limit on the number of epoll instances imposed by
/proc/sys/fs/epoll/max_user_instances
was encountered(冲突). See epoll(7) for further details. EMFILE The per-process limit on the number of open file descriptors has been reached.
ENFILE The system-wide limit on the total number of open files has been reached.
ENOMEM There was insufficient memory to create the kernel object.
版本:
epoll_create() 是在linux 2.6加进内核的.Library support is provided in glibc starting with version 2.3.2.
epoll_create1() was added to the kernel in version 2.6.27. Library support is provided in glibc starting with version 2.9.
CONFORMING TO
- epoll_create() is Linux-specific.
注意
- In the initial epoll_create() implementation, 参数 size 告诉内核函数调用希望加到实例的描述符个数,内核用这个信息作为依据用于在初始化时申请结构events空间. (如果有必要,内核会申请更多的空间如果函数使用超过size),现在这个参数已经没有必要了,但是还是要大于0以保证向前的兼容性。
SEE ALSO
close(2), epoll_ctl(2), epoll_wait(2), epoll(7)COLOPHON
- This page is part of release 4.04 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page,can be found at http://www.kernel.org/doc/man-pages/.
Linux 2015-12-28 EPOLL_CREATE(2)