AIO_WAITCOMPLETE(2)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… AIO_WAITCOMPLETE(2) πŸ’…

ok so bestie, you're looking at the System Calls Manual β€” this is the page for aio_waitcomplete, and honestly? It's a little baddie. Let's get into it πŸŽ€


✨ NAME ✨

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


πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc) β€” she's built in, no extra shopping required πŸ’–


🧚 SYNOPSIS 🧚

#include <aio.h>

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

That's the whole vibe. Two args, one return, zero drama (mostly). ⭐


🌸 DESCRIPTION 🌸

So aio_waitcomplete() is a system call that waits for the completion of an asynchronous I/O request. It's giving "I'll be right there, just let me finish this." ⏳

The moment that request completes, 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 completed before you even called aio_waitcomplete()? It returns immediately with that completed request β€” no waiting, instant slay πŸ’…

Now if timeout is a non-NULL pointer, it specifies a maximum interval to wait for an asynchronous I/O request to complete. If timeout is a NULL pointer, aio_waitcomplete() waits indefinitely β€” that's main character commitment, no cap. πŸ•°οΈ

And to effect a poll, the timeout argument should be non-NULL, pointing to a zero-valued timeval structure. Lowkey genius.

🚨 Important bestie moment: 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. Do not double-dip, I'm begging πŸ™ˆ

πŸ’œ 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) β€” so go read those pages, iykyk 🌈

On failure, aio_waitcomplete() returns -1, sets iocbp to NULL, and sets errno to indicate the error condition. Sad girl hours 😭


πŸ”₯ ERRORS πŸ”₯

The aio_waitcomplete() system call fails if:

  • [EAGAIN] β€” The process has not yet called aio_read() or aio_write(). Like bestie… you gotta start something before you can finish it πŸ’€
  • [EINTR] β€” A signal was delivered before the timeout expired and before any asynchronous I/O requests completed. Interrupted, respectfully 🫢
  • [EINVAL] β€” The specified time limit is invalid. That clock is not clocking πŸ•°οΈ
  • [EWOULDBLOCK]
  • [EINPROGRESS] β€” The specified time limit expired before any asynchronous I/O requests completed. Time ran out, nothing finished, it's giving waiting-room energy πŸŽ€

πŸ‘‘ 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 friend group, go say hi πŸ’–


⭐ STANDARDS ⭐

The aio_waitcomplete() system call is a FreeBSD-specific extension. Exclusive. FreeBSD-only. We don't gatekeep but also we kinda do πŸ’…


πŸ¦‹ HISTORY πŸ¦‹

The aio_waitcomplete() system call first appeared in FreeBSD 4.0. Iconic since day one, fr fr πŸ‘‘


πŸ“ AUTHORS πŸ“

The aio_waitcomplete() system call and this manual page were written by Christopher M Sedore <cmsedore@maxwell.syr.edu>. We love a legend who documents their own work, no cap πŸ”₯


and that's the whole page bestie! this one's from the Debian fam, dated March 27, 2025, and it's for AIO_WAITCOMPLETE(2). go forth and await your completions πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from