epoll_create1()¶
Purpose¶
Creates an epoll instance and returns a file descriptor used by epoll_ctl() and epoll_wait().
Header¶
Prototype¶
Parameters¶
flags: normallyEPOLL_CLOEXECor0.
Return Value¶
- Success: returns a new epoll file descriptor.
- Failure: returns
-1and setserrno.
Minimal Example¶
Common Pitfalls¶
- Prefer
EPOLL_CLOEXECto avoid leaking the fd acrossexec(). - Close the epoll fd during cleanup.
epoll_create()is older; preferepoll_create1()for new code.