aio_suspend(3)
π€ aio_suspend(3) β wait for asynchronous I/O operation or timeout
okay bestie, this one lives in the Library Functions Manual (section 3), so you know it's a library call π
π LIBRARY
Real-time library β link it with librt, so -lrt on your compile line π
β¨ SYNOPSIS
#include <aio.h>
int aio_suspend(int n;
const struct aiocb *const aiocb_list[n], int n,
const struct timespec *restrict timeout);
(yes the synopsis is built different, we don't question it, we just vibe π)
πΈ DESCRIPTION
so aio_suspend() basically puts your calling thread in timeout mode π β it suspends the calling thread until one of these things happens:
- one or more of the async I/O requests in the list
aiocb_listhas completed β - a signal gets delivered π¬
timeoutis not NULL and the time interval you specified has officially passed β° (want the deets on thetimespecstruct? go seenanosleep(2))
The n argument tells you how many items are chillin' in aiocb_list. Every single item in that list pointed to by aiocb_list has to be either NULL (in which case it's just ignored, lowkey irrelevant, we move on π) or a pointer to a control block where I/O was started using aio_read(3), aio_write(3), or lio_listio(3). Want the whole aiocb structure explained? That's aio(7), babes.
If CLOCK_MONOTONIC is supported, that's the clock used to measure the timeout interval β peep clock_gettime(2) for that.
π«Ά RETURN VALUE
- if the function comes back because one of the I/O requests in
aiocb_listfinished? you get 0 β slay β¨ - otherwise you get -1, and
errnois set to tell you what went wrong π
π ERRORS
EAGAINβ the call hit the timeout before any of the indicated operations had completed. it literally just ran out of time bestie β³EINTRβ the call got ended by a signal (possibly the completion signal of one of the operations you were waiting on, which is so ironic ngl); seesignal(7)ENOSYSβaio_suspend()is not implemented. it's giving "we don't do that here" π
π ATTRIBUTES
for what all these terms even mean, check attributes(7).
- Interface:
aio_suspend() - Attribute: Thread safety
- Value:
MT-Safeπ₯
π STANDARDS
POSIX.1-2008.
π¦ HISTORY
glibc 2.1. Also POSIX.1-2001.
And a lil note: POSIX doesn't specify the parameters to be restrict β that part is specific to glibc, so don't go thinking every lib does it π
π NOTES
- wanna poll? you absolutely can β just pass a non-NULL
timeoutthat specifies a zero time interval π - if one or more of the async I/O ops in
aiocb_listhas already completed by the time you callaio_suspend(), the call returns immediately. no waiting, no drama, instant πΈ - to figure out which I/O operations actually completed after a successful return from
aio_suspend(), useaio_error(3)to scan through the list ofaiocbstructures pointed to byaiocb_listπ
π BUGS
The glibc implementation ofaio_suspend()is not async-signal-safe, which is in violation of the requirements ofPOSIX.1. so yeah. that's a thing. be careful out there π©
π SEE ALSO
aio_cancel(3), aio_error(3), aio_fsync(3), aio_read(3), aio_return(3), aio_write(3), lio_listio(3), aio(7), time(7)
mwah, that's the whole page π this lil masterpiece came from Linux man-pages 6.20, dated 2026-02-08 β and with that, aio_suspend(3) is a wrap, periodt β¨ππ«Ά
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: GPL-2.0-or-later
- Copyright 2003, Andries E. Brouwer <aeb@cwi.nl>
- Copyright 2010, Michael Kerrisk <mtk.manpages@gmail.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms