AIO_WAITCOMPLETE(2)

πŸ’– aio_waitcomplete β€” the "bestie, is my async I/O done yet??" syscall

okay so this is from the System Calls Manual, section 2 (that's the syscall girlies πŸ’…). It lives in aio_waitcomplete(2) and it's about to become your new hyperfixation, no cap.


✨ NAME ✨

aio_waitcomplete β€” wait for the next completion of an aio request

like literally, it sits there and waits for one (1) async I/O request to finish. that's the whole vibe.


πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc)

link it, love it, it's free 🫢


🌸 SYNOPSIS 🌸

#include <aio.h>

ssize_t
aio_waitcomplete(struct aiocb **iocbp, struct timespec *timeout);

πŸ¦‹ DESCRIPTION πŸ¦‹

The aio_waitcomplete() system call waits for completion of an asynchronous I/O request. When it's done, aio_waitcomplete() returns the result of the function and sets iocbp to point to the structure associated with the original request. And if an asynchronous I/O request already finished before you even called aio_waitcomplete()? It returns immediately with that completed request. no waiting, instant slay ✨

If timeout is a non-NULL pointer, it specifies a maximum interval to wait for a asynchronous I/O request to complete. If timeout is a NULL pointer, aio_waitcomplete() waits indefinitely β€” like, forever-forever, main character patience 🧘

To effect a poll, the timeout argument should be non-NULL, pointing to a zero-valued timeval structure. so basically: "do u have anything for me rn or not, no pressure" πŸ’…

ok this part is important bestie, don't skip it: The aio_waitcomplete() system call also serves the function of aio_return(), thus aio_return() should not be called for the control block returned in iocbp. it's giving two-for-one, but also it's giving "do NOT double-dip, I am warning u" 😭

πŸ”₯ RETURN VALUES πŸ”₯

If an asynchronous I/O request has completed, iocbp is set to point to the control block passed with the original request, and the status is returned as described in read(2), write(2), or fsync(2). iconic behaviour, honestly πŸ‘‘

On failure, aio_waitcomplete() returns -1, sets iocbp to NULL and sets errno to indicate the error condition. yeah... it's not beating the failure allegations πŸ’€


πŸ’€ ERRORS πŸ’€

The aio_waitcomplete() system call fails if:

  • [EINVAL] β€” The specified time limit is invalid. girl what kind of time is that 😭
  • [EAGAIN] β€” The process has not yet called aio_read() or aio_write(). you showed up to the party with no I/O queued, embarrassing fr fr πŸ™ˆ
  • [EINTR] β€” A signal was delivered before the timeout expired and before any asynchronous I/O requests completed. something interrupted ur little moment, rude.
  • [EWOULDBLOCK]
  • [EINPROGRESS] β€” The specified time limit expired before any asynchronous I/O requests completed. clock ran out, nothing landed, the audacity ⏰

πŸŽ€ SEE ALSO πŸŽ€

aio_cancel(2), aio_error(2), aio_read(2), aio_return(2), aio_suspend(2), aio_write(2), fsync(2), read(2), write(2), aio(4)

the whole aio friend group, go read them all, iykyk πŸ’œ


⭐ STANDARDS ⭐

The aio_waitcomplete() system call is a FreeBSD-specific extension. not portable bestie, it's a FreeBSD exclusive 🏝️


🌈 HISTORY 🌈

The aio_waitcomplete() system call first appeared in FreeBSD 4.0. vintage. a classic. we stan an elder ✨


πŸ‘‘ AUTHORS πŸ‘‘

The aio_waitcomplete() system call and this manual page were written by Christopher M Sedore <cmsedore@maxwell.syr.edu>. thank u for ur service king πŸ«‘πŸ’–


ok that's the whole page bestie, u ate that. go queue some async I/O and wait on it like the icon u are πŸ’…βœ¨

this lil doc came from the Debian pack, dated March 21, 2016 β€” yeah it's older than some of us but it still hits πŸŽ€

πŸ“¦ where this page comes from