io_passfd(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_passfd(3) β€” bestie edition

ok so this is a page from the Library Functions Manual, and the star of the show is io_passfd(3). pull up a chair 🫢


✨ NAME ✨

io_passfd β€” slide a whole file descriptor across a Unix Domain socket like it's a note in class πŸ’Œ


🌸 SYNTAX 🌸

#include <libowfat/io.h>

int io_passfd(int64 sock,int64 fd);

πŸ¦‹ DESCRIPTION πŸ¦‹

okay bestie, listen. io_passfd transfers the file descriptor fd over the Unix Domain socket sock. that's the whole vibe. πŸ”₯

and like… it works much like dup(2), except the plot twist is that the copy of the descriptor does not show up in this process. nope. it appears at the other end of the Unix Domain socket instead. which means that other end has to be a process on the same system. no long-distance relationships here, sorry πŸ’€

the peer over there can then use io_receivefd(3) to receive the file descriptor. iconic teamwork, no cap. πŸ‘‘

⚠️ important bestie note: the passed descriptor stays open in the sending process. it does not get closed on your end. so don't be out here acting surprised when it's still hanging around, okay? 😭

πŸŽ€ RETURN VALUE πŸŽ€

  • io_passfd returns 0 on success πŸ’–
  • -1 on error, and it sets errno accordingly πŸ™ˆ

that's it, that's the whole deal.


🌈 SEE ALSO 🌈

  • io_receivefd(3) β€” the other half of the friendship, the one who catches what you threw πŸ’œ

made with love, from the Library Functions Manual, page io_passfd(3) β€” mwah πŸ’…βœ¨