io_fd(3)

πŸ“¦
version 0.34 Β· 3 versions
, in alpine 3.24, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu resolute, ubuntu stonking

πŸ’… io_fd β€” bestie's guide to prepping a descriptor πŸ’…

okay so. welcome to io_fd, a lil function from libowfat's io family (that's the Library Functions Manual, for the record). its whole job? getting a descriptor ready so io_wait knows you care about it. that's it. that's the girl. ✨


✨ SYNOPSIS ✨

#include <libowfat/io.h>

int io_fd(int64 fd);

🌸 DESCRIPTION 🌸

so here's the tea, bestie. if you wanna use io_canread() and io_canwrite() on a descriptor, you have to run io_wait() on it first β€” and io_wait() has to actually know which descriptors you're interested in. that's where io_fd() comes in. it tells io_wait() "hey, i'm interested in this fd, keep an eye on her." πŸ‘€

now, if you already know the descriptor is writable, call io_fd_canwrite() instead. most fresh descriptors are writable, like if it came from pipe(2) or socketpair(2) or accept(2). doing that saves you one syscall, and saving syscalls is lowkey self-care. πŸ’–

also, io_pipe and io_socketpair already call io_fd_canwrite() for you, so you don't gotta do a thing. they got you. 🫢

⚠️ okay important part, no skipping: waiting on descriptors only works for sockets, fifos and pipes. it may also work on devices and TTYs, but that's platform dependent β€” do not rely on that, fr fr. and it does not work on files. like, at all. don't even try it, it's giving disappointment. πŸ’€

πŸ”₯ RETURN VALUE πŸ”₯

  • io_fd returns 1 on success, and 0 on error.

that's it. binary queen. πŸ‘‘


πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie β€” this was io_fd(3) from the Library Functions Manual (the libowfat crew, no cap), and there's no version or date info on this one so i can't spill what i don't have πŸ™ˆ. now go forth and prep those descriptors. slay. πŸ’…βœ¨πŸŽ€πŸ¦‹