AIO_WAITCOMPLETE(2)
π 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: theaio_waitcomplete()system call also serves the function ofaio_return(), thusaio_return()should not be called for the control block returned iniocbp. 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 calledaio_read()oraio_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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 1999 Christopher M Sedore
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms