2020-12-17

Eventfd

An eventfd contains a 32 bit integer maintained by the kernel.

Creating an eventfd:

let init_val = 0;
let flags = libc::EFD_CLOEXEC | libc::EFD_NONBLOCK;
libc::eventfd(init_val, flags);

// Register with libc::EPOLLIN | libc::EPOLLET

Write a value greater than zero to an instance of eventfd to notify user space. Reading it will then reset it to zero.

All other reads will get "Resource Temporarily Unavailable", until it's written again.