io_cancel(3)
π io_cancel(3) β the Linux AIO girlies' guide to cancelling ur io requests π
okay so bestie, welcome to io_cancel from the Linux AIO manual (that's section 3, library calls, iykyk) β¨ this one is literally about calling off io requests you already sent out. no cap, it's giving "unsend that message" energy π«Ά
β¨ NAME β¨
io_cancel β cancel io requests π
πΈ SYNOPSIS πΈ
#include <errno.h>
#include <libaio.h>
int io_cancel(io_context_t ctx, struct iocb *iocb);
struct iocb {
void *data; /* Return in the io completion event */
unsigned key; /* For use in identifying io requests */
short aio_lio_opcode;
short aio_reqprio; /* Not used */
int aio_fildes;
};
yes queen, that struct is exactly as it appears, don't you dare touch a character of it π
π¦ DESCRIPTION π¦
So like β this function attempts to cancel an iocb that you previously passed to io_submit(3). π
If the operation gets successfully cancelled, the resulting event is copied into the memory pointed to by result without being placed into the completion queue. iconic behavior honestly β¨
And here's when you'd actually want this: when one or more requests are being processed asynchronously, it might be useful in some situations to cancel a selected operation. Like, for example, if it becomes obvious that the written data is no longer accurate and would have to be overwritten soon π. The example the manpage gives: assume an application which writes data in files, in a situation where new incoming data would have to be written in a file which will be updated by an enqueued request. very "oops that draft was stale" of it π
π RETURN VALUES π
0 is returned on success β slay π β otherwise it returns errno. yep, we're in errno territory, bestie.
π ERRORS π
EFAULTβ if any of the data structures pointed to are invalid. girl those pointers are not pointing anywhere good πEINVALβ if theaio_contextspecified byctxis invalid. nope, that context is not it πEAGAINβ if theiocbspecified was not cancelled. it said "no <3" πENOSYSβ if not implemented. literally not a thing here, sorry bestie πΈ
π SEE ALSO π
io(3), io_fsync(3), io_getevents(3), io_prep_fsync(3), io_prep_pread(3), io_prep_pwrite(3), io_queue_init(3), io_queue_release(3), io_queue_run(3), io_queue_wait(3), io_set_callback(3), io_submit(3), errno(3).
friendly reminder bestie: the whole point is that a successful cancel means the event lands where result points and does not go into the completion queue. don't go looking for it there, she's not coming π
okay that's the whole page!! π this version of the page is from the Linux manual, dated 2019-07-23, and it's io_cancel(3) β go forth and cancel responsibly, mwah ππ¦β¨
π¦ where this page comes from
- alpine 3.22: libaio-doc 0.3.113-r2 Β· LGPL-2.1-or-later
- alpine 3.23: libaio-doc 0.3.113-r2 Β· LGPL-2.1-or-later
- alpine 3.24: libaio-doc 0.3.113-r2 Β· LGPL-2.1-or-later
- arch rolling: libaio 0.3.113-5 Β· LGPL-2.0-or-later
- debian bookworm: libaio-dev 0.3.113-4 Β· LGPL-2.1-or-later
- debian trixie: libaio-dev 0.3.113-8+b1 Β· LGPL-2.1-or-later
- ubuntu jammy: libaio-dev 0.3.112-13build1 Β· LGPL-2.1-or-later
- ubuntu noble: libaio-dev 0.3.113-6build1 Β· LGPL-2.1-or-later
- ubuntu noble: libaio-dev 0.3.113-6build1.1 Β· LGPL-2.1-or-later
- ubuntu questing: libaio-dev 0.3.113-8
- ubuntu resolute: libaio-dev 0.3.113-8build1 Β· LGPL-2.1-or-later
- ubuntu stonking: libaio-dev 0.3.113-9 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms