io_set_callback(3)
β¨ io_set_callback(3) β¨
okay bestie, we're in the Linux AIO section of the manual, and today's main character is io_set_callback β the lil helper that hooks your completion callback up to an iocb. it's a <libaio.h> girlie, she's static inline, she's lowkey iconic. let's get into it π
πΈ NAME πΈ
io_set_callback β set up the io completion callback function π
π¦ SYNOPSIS π¦
#include <errno.h>
#include <libaio.h>
static inline void io_set_callback(struct iocb *iocb, io_callback_t cb);
struct iocb {
void *data;
unsigned key;
short aio_lio_opcode;
short aio_reqprio;
int aio_fildes;
};
typedef void (*io_callback_t)(io_context_t ctx, struct iocb *iocb, long res, long res2);
like yes, that's a whole struct AND a typedef in the synopsis, she's thorough, we respect it π«Ά
π DESCRIPTION π
so here's the tea, bestie: the callback is not done if the caller uses raw events from io_getevents(3). nope, not happening. it only fires with the library helpers. that's the whole vibe. no cap.
β οΈ fr fr β if you're pulling raw events straight out of io_getevents(3), your callback is just not going to run. it's giving ghosted. π
β RETURN VALUES β
None. literally nothing. void behavior, void energy, she returns nothing and that's fine π
π ERRORS π
None. no errors, no drama, we love a low-maintenance queen π
π SEE ALSO π
io(3)io_cancel(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_submit(3)errno(3)
go read all of them, i'll wait, they're all part of the same friend group π
and that's the page!! this one's from the Linux crew, dated 2019-07-23, so yeah she's been serving accurate documentation since way back. mwah, bye bestie πβ¨π
π¦ 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