aio_cancel(3)

πŸ’– NAME πŸ’–

aio_cancel β€” cancel an outstanding asynchronous I/O request, bestie. like, we're calling it off. no hard feelings. mostly.


πŸ“š LIBRARY πŸ“š

Real-time library β€” link it with librt, -lrt. that's the whole vibe.


✨ SYNOPSIS ✨

#include <aio.h>

int aio_cancel(int fd, struct aiocb *aiocbp);

🫢 DESCRIPTION 🫢

okay so aio_cancel() is out here trying to cancel outstanding asynchronous I/O requests for the file descriptor fd. that's its whole job. iconic of it honestly.

if aiocbp is NULL? then ALL such requests get canceled, like a mass unfollow. otherwise, only the one request described by the control block pointed to by aiocbp gets canceled. just the one. targeted. (and if you need the whole tea on what the aiocb structure even is, go look at aio(7) β€” it's all laid out there.)

normal asynchronous notification still happens for canceled requests, mmkay? (peep aio(7) and sigevent(3type) for that whole situation). and when a request gets canceled:

  • the request return status (aio_return(3)) gets set to -1 😭
  • the request error status (aio_error(3)) gets set to ECANCELED πŸ™ˆ

but listen β€” the control block of requests that cannot be canceled? it does not get changed. leave it alone, it's fine, it's doing its thing.

if the request could NOT be canceled, then it's just gonna terminate in the usual way after it finishes performing the I/O operation. like okay, we respect the commitment. (in this case, aio_error(3) will return the status EINPROGRESSS.)

🚨 WARNING, bestie, this one's real: if aiocbp is not NULL, and fd differs from the file descriptor with which the asynchronous operation was initiated β€” unspecified results occur. unspecified!! we do not know what happens!! do not do this!! πŸ’€

and which operations are even cancelable? that's implementation-defined, so it depends on your implementation. not our call. periodt.


πŸŽ€ RETURN VALUE πŸŽ€

aio_cancel() returns one of these little guys:

  • AIO_CANCELED β€” slay, all requests were successfully canceled πŸ’…
  • AIO_NOTCANCELED β€” at least one of the requests specified was not canceled because it was in progress. in this case you can check the status of individual requests using aio_error(3)
  • AIO_ALLDONE β€” all requests had already been completed before the call. they finished without you, babe 😭
  • -1 β€” an error occurred πŸ˜” you can find the error by inspecting errno

πŸ”₯ ERRORS πŸ”₯

  • EBADF β€” fd is not a valid file descriptor. that fd is a fake, a fraud 🌸
  • ENOSYS β€” aio_cancel() is not implemented. it's giving "we simply don't do that here"

πŸ‘‘ ATTRIBUTES πŸ‘‘

for an explanation of the terms used in this section, see attributes(7). (no tables from me, bestie, just vibes and facts:)

  • aio_cancel() | Thread safety | MT-Safe
✨ translation: aio_cancel() is MT-Safe. multiple threads can call it, no drama. we love a thread-safe queen 🫢

🌈 STANDARDS 🌈

POSIX.1-2008. certified. πŸ’œ


πŸ¦‹ HISTORY πŸ¦‹

glibc 2.1. POSIX.1-2001. it's been around for a minute, lowkey a legend at this point. ⭐


πŸ“ EXAMPLES πŸ“

see aio(7). that's where the examples live, bestie, i'm not gonna make up new ones for you. πŸ’–


πŸ’œ SEE ALSO πŸ’œ

aio_error(3), aio_fsync(3), aio_read(3), aio_return(3), aio_suspend(3), aio_write(3), lio_listio(3), aio(7)

go read the whole friend group, they're all connected, iykyk 🧚


and that's the page!! mwah πŸ’‹ this one came from Linux man-pages 6.20, dated 2026-02-08, and it's fine, it's gorgeous, it's aio_cancel(3) and she ate. no cap. πŸŽ€βœ¨

πŸ“¦ 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