c - When will eventfd_read() block? -
i wonder under situation eventfd_read()
block?
i read manpage doesn't mention anything.
i created file descriptor through eventfd(0,0)
.
thanks in advance.
from eventfd(2)
man page read()
call:
if eventfd counter 0 @ time of call read(2), call either blocks until counter becomes nonzero (at time, read(2) proceeds described above) or fails error eagain if file descriptor has been made nonblocking.
and eventfd_read()
, eventfd_write()
functions:
the functions perform read , write operations on eventfd file descriptor, returning 0 if correct number of bytes transferred, or -1 otherwise.
so eventfd_read()
wrapper read()
, blocks when read()
blocks, i.e. when eventfd
counter 0 , o_nonblock
not set descriptor (using fcntl(2)
or efd_nonblock
).
you can verify in glibc sources:
int eventfd_read (int fd, eventfd_t *value) { return __read (fd, value, sizeof (eventfd_t)) != sizeof (eventfd_t) ? -1 : 0; }
Comments
Post a Comment