The sendfd program()

The sendfd program

    sendfd socket fd [...] [: command arg ...]

sendfd passes one or more inherited file descriptors over a Unix-domain socket (such as those opened with s6-ipcclient (https://skarnet.org/software/s6/s6-ipcclient.html)/s6-ipcserver (https://skarnet.org/software/s6/s6-ipcserver.html) or ucspi-unix (https://untroubled.org/ucspi-unix/)). Another process that has a descriptor for the other end of the socket can receive the descriptors using the fd_xfer_recv(), fd_xfer_child(), or fd_xfer_ucspi() library functions. The received descriptors will not necessarily have the same numeric values, but will refer to the same open file handles, as if by dup(). After passing the descriptors, sendfd execs the given command, if any. A colon separates the file descriptors from the command.

This is useful, for example, in network clients that want to use UCSPI client programs to establish connections, but which can't have all connections opened at startup. When the client is ready to open a new connection, it can create a socket using socketpair(), and then spawn tcpclient (or any other UCSPI client), with sendfd given to tcpclient as a subcommand to pass the new connection descriptor back to the original process over the socketpair() socket.