io_queue_wait(3)

io_queue_wait(3) πŸ’–

okay bestie, so this one is from the Linux AIO corner of the universe (yes, the libaio girlies, we exist) 🌸 she's a lil 3-page-section baddie and she's here to tell you how to wait for your io requests to finish. patient queen energy. πŸ‘‘


✨ NAME ✨

io_queue_wait β€” literally just sitting there waiting for io requests to complete 🫢


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <errno.h>

#include <libaio.h>

int io_queue_wait(io_context_t ctx, const struct timespec *timeout);

like, that's the whole thing. two includes, one function. minimal. iconic. πŸ’…


🌸 DESCRIPTION 🌸

so io_queue_wait() tries to read an event from the completion queue for the aio context you handed it in ctx. that's it. that's the vibe check. it's giving "hey, did any of my requests finish yet?" πŸ’–


πŸ’œ RETURN VALUES πŸ’œ

may return 0 if no events are available and the timeout specified by when has elapsed β€” and when == NULL means an infinite timeout, no cap, she'll wait forever fr fr 😭

heads up bestie: the timeout that when points to is relative, and it will get updated if it's not NULL and the operation blocks. so don't be surprised when your timespec comes back looking different, that's just how she moves. πŸ’€

and if it's not implemented at all, she fails with -ENOSYS. not everything gets to exist, and that's okay. πŸ™ˆ


πŸŽ€ RETURN VALUES πŸŽ€

(she has two of these sections, and honestly? slay, we love a queen who says it twice. πŸ’…)

on success, io_queue_wait() returns 0. otherwise you get -error, where error is one of the Exxx values defined in the Errors section. periodt.


πŸ”₯ ERRORS πŸ”₯

  • EFAULT β€” iocbs referenced data outside of the program's accessible address space. like, girl, that memory is not yours, stay in your lane. πŸ’€
  • EINVAL β€” ctx refers to an uninitialized aio context, or the iocb pointed to by iocbs contains an improperly initialized iocb. something's not set up right bestie, go check it. 🫢
  • ENOSYS β€” not implemented. she simply does not exist here. 😭

🌈 SEE ALSO 🌈

the whole friend group, basically. go read them too, iykyk. 🧚


this page came straight out of Linux, dated 2019-07-23, and yes she's still serving. mwah. πŸ’œβœ¨