SENDFD(3)
okay bestie, welcome to sendfd(3) β straight out of the Library Functions Manual β and itβs literally the page for sendfd and recvfd, the little duo that passes file descriptors along Unix domain sockets. no cap, itβs giving kernel handoff magic β¨
β¨ NAME β¨
sendfd, recvfd β pass file descriptors along Unix domain sockets π¦
π¦ SYNOPSIS π¦
#include <u.h>
#include <libc.h>
int sendfd(int socket, int fd)
int recvfd(int socket)
π DESCRIPTION π
okay so hereβs the vibe: recvfd and sendfd can be used to pass an open file descriptor over a Unix domain socket from one process to another. π
and since pipe(3) is implemented with socketpair(2) instead of pipe(2), socket can be a file descriptor obtained from pipe(3). iykyk π
sendfd sends the file descriptor fd along the socket to a process calling recvfd on the other end. literally passing the fd handoff π«Ά
it is assumed that the two sides have coordinated and agreed to transfer a file descriptor already, so that the sendfd is met with a recvfd instead of an ordinary read. like, both sides have to be in on the plan fr fr π
the file descriptor number may change on its way between processes, but the kernel structure it represents will not. so the number might do a little glow-up, but the kernel structure it represents stays exactly what it is π
π SOURCE π
/src/lib9/sendfd.c β thatβs where this lives, periodt π
π SEE ALSO π
socketpair(2)π¦sendmsginsend(2)πΈ
π and thatβs the whole page! the footer is just SENDFD(3) β no extra version or date listed, so consider this your cute sign-off. mwah π
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms