Expand description
eventfd – Event notification file descriptor
Provides a file descriptor for event wait/notify, commonly used by epoll-based event loops (Qt6, glib). Supports both counter and semaphore semantics.
§Syscall Interface
eventfd_create(initval, flags) -> fd(syscall 330)- Read/write via standard
read(2)/write(2)on returned fd
§Semantics
- write: Adds the 8-byte unsigned integer to the internal counter.
Blocks (or returns EAGAIN) if the counter would overflow
u64::MAX - 1. - read: Returns the current counter as an 8-byte unsigned integer and resets it to zero. In semaphore mode, returns 1 and decrements by 1. Blocks (or returns EAGAIN) if the counter is zero.
Structs§
- Event
FdNode - VfsNode wrapper around an eventfd instance.
Constants§
- EFD_
CLOEXEC - EFD_CLOEXEC flag: set close-on-exec (tracked but not enforced in kernel).
- EFD_
NONBLOCK - EFD_NONBLOCK flag: reads/writes return EAGAIN instead of blocking.
- EFD_
SEMAPHORE - EFD_SEMAPHORE flag: read returns 1 and decrements (instead of draining).
Functions§
- eventfd_
close - Close (destroy) an eventfd instance.
- eventfd_
create - Create a new eventfd.
- eventfd_
read - Read from an eventfd. Returns the counter value as a u64.
- eventfd_
write - Write to an eventfd. Adds
valueto the internal counter. - is_
readable - Query whether an eventfd is readable (counter > 0). Used by epoll to check readiness without consuming data.
- is_
writable - Query whether an eventfd is writable (counter < u64::MAX - 1).