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 toECANCELEDπ
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 usingaio_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 inspectingerrno
π₯ 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
- Copyright 2003, Andries E. Brouwer <aeb@cwi.nl>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms