io_receivefd(3)

πŸ“¦
version 0.34 Β· 2 versions
  • 0.34 Β· alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 0.30 Β· fedora 43, fedora 44, ubuntu jammy
, in alpine 3.24, debian bookworm, debian trixie, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

io_receivefd πŸ’Œ

okay bestie, so this one's from the Library Functions Manual β€” yes we're reading man pages for fun now, it's giving study date energy πŸŽ€


✨ NAME ✨

io_receivefd β€” receive a file descriptor over a Unix Domain socket 🫢

like, somebody slid a whole fd into your DMs. except the DMs are a Unix Domain socket. iykyk.


🌸 SYNTAX 🌸

#include <libowfat/io.h>

int64 io_receivefd(int64 sock);

πŸ’– DESCRIPTION πŸ’–

so io_receivefd receives a file descriptor from the Unix Domain socket called sock. the way that a file descriptor can just... travel through a socket... iconic behavior honestly πŸ’…

and if you wanna be the one doing the sending? that's a whole other function, bestie β€” you send a descriptor using io_passfd(3). it's giving pen pals. it's giving "here, hold this fd for me" πŸ¦‹

heads up: io_receivefd returns -1 on error, or the file descriptor if it worked. that's the whole vibe check β€” -1 means we're in our flop era, anything else is your new fd ✨

okay and now the messy part πŸ™ˆ the underlying Unix API is lowkey extra and can send more than one descriptor at the time. this function? it expects only one descriptor. so if more than one got sent, it will return the first one and just... not address the rest. no cap, that's the behavior. so don't come crying to me about the other fds, they're still in the socket's inbox πŸ’€


πŸŽ€ SEE ALSO πŸŽ€

  • io_passfd(3) β€” the sender half of this situationship πŸ’ž

that's the whole page, bestie!! go forth and receive your file descriptors responsibly 🌈

β€” from the Library Functions Manual, filed under io_receivefd(3), mwah πŸ’‹