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_list has completed βœ…
  • a signal gets delivered πŸ“¬
  • timeout is not NULL and the time interval you specified has officially passed ⏰ (want the deets on the timespec struct? go see nanosleep(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_list finished? you get 0 β€” slay ✨
  • otherwise you get -1, and errno is 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); see signal(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 timeout that specifies a zero time interval πŸ”
  • if one or more of the async I/O ops in aiocb_list has already completed by the time you call aio_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(), use aio_error(3) to scan through the list of aiocb structures pointed to by aiocb_list πŸ”

πŸ’€ BUGS

The glibc implementation of aio_suspend() is not async-signal-safe, which is in violation of the requirements of POSIX.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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms