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 πŸ‘‘

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 πŸŽ€βœ¨πŸ’–