epoll_create(2)
โจ epoll_create(2) โจ โ the System Calls Manual, but make it cute ๐
okay so bestie, this is epoll_create and epoll_create1 from section 2 of the manual. System calls, babes. Let's get into it ๐ฆ
๐ NAME ๐
epoll_create, epoll_create1 โ open an epoll file descriptor ๐
๐ LIBRARY ๐
Standard C library (libc, -lc)
๐ธ SYNOPSIS ๐ธ
#include <sys/epoll.h>
int epoll_create(int size);
int epoll_create1(int flags);
๐ DESCRIPTION ๐
epoll_create() makes you a brand new epoll(7) instance. it's giving new beginnings โจ
ngl the tea on size: since Linux 2.6.8 it's literally justโฆ ignored ๐ but bestie it must still be greater than zero or it's a whole thing. check HISTORY for the lore.
epoll_create() hands you back a file descriptor pointing at your new epoll instance. that fd is your main character for every subsequent call into the epoll interface. and when you're done with it?? close it with close(2), periodt ๐
once all the file descriptors pointing at an epoll instance are closed, the kernel destroys the instance and releases all the associated resources so they can be reused. so clean, so iconic ๐
๐ง epoll_create1() ๐ง
if flags is 0, then epoll_create1() is the same as epoll_create() โ except the obsolete size argument is just dropped, no big deal, we don't talk about her anymore ๐
you can stick the following value in flags to get different behavior:
EPOLL_CLOEXECโ sets the close-on-exec (FD_CLOEXEC) flag on your shiny new file descriptor. for the why-is-this-even-useful of it all, go read about theO_CLOEXECflag inopen(2). iykyk ๐ซถ
๐ฅ RETURN VALUE ๐ฅ
on success, these system calls return a file descriptor (a nonnegative integer). slay. ๐
on error, -1 is returned and errno is set to tell you what went wrong ๐ญ
๐ ERRORS ๐
EINVALโsizeis not positive. she said "must be greater than zero" and you said "no" ๐EINVALโ (epoll_create1()only) invalid value specified inflags.EMFILEโ the per-process limit on the number of open file descriptors has been reached. that's a lot of fds, bestie ๐ซENFILEโ the system-wide limit on the total number of open files has been reached. the whole machine said enough.ENOMEMโ there was insufficient memory to create the kernel object. no thoughts, no memory, head empty ๐
โญ STANDARDS โญ
Linux. ๐ง
๐ HISTORY ๐
epoll_create()โ Linux 2.6, glibc 2.3.2.epoll_create1()โ Linux 2.6.27, glibc 2.9.
so the lore ๐
in the initial epoll_create() implementation, that size argument actually told the kernel how many file descriptors the caller expected to add to the epoll instance. the kernel used that as a hint for how much space to initially allocate in its internal data structures describing events. and if the caller's usage ended up exceeding the hint in size, the kernel would just allocate more space as needed. no stress. โจ
these days that hint is not required anymore โ the kernel dynamically sizes the required data structures all by itself, no hint needed, she's independent ๐
โ but size still has to be greater than zero, and that's purely for backward compatibility so that new epoll applications can still run on older kernels. respect the elders ๐
also: prior to Linux 2.6.29, there was a /proc/sys/fs/epoll/max_user_instances kernel parameter that limited live epolls for each real user ID, and it caused epoll_create() to fail with EMFILE when you overran it. rip to her, she's gone now ๐ญ
๐ SEE ALSO ๐
close(2), epoll_ctl(2), epoll_wait(2), ioctl_eventpoll(2), epoll(7)
and that's the whole page, bestie โ brought to you by Linux man-pages 6.20, dated 2026-02-08, and yes that's epoll_create(2) because we stay in section 2 around here ๐โจ go forth and file-descriptor responsibly ๐
๐ฆ where this page comes from
- arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- ๐ the page's license: GPL-2.0-or-later
- Copyright 2003, Davide Libenzi <davidel@xmailserver.org>
- Copyright 2009-2019, Michael Kerrisk <tk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms