groff 1.23.0 added .MR to its -man macro package. The NEWS file states
that the inclusion of the macro "was prompted by its introduction to
Plan 9 from User Space's troff in August 2020." From d32deab it seems
that the name for Plan 9 from User Space's implementation was suggested
by groff maintainer G. Brandon Robinson.
Not sure if the intention was to make these definitions compatible, but
it would be nice if they were.
Currently, Plan 9 from User Space's .MR expects its second argument to
be parenthesized. groff's .MR does not. This results in extra
parentheses appearing in manual references when viewing Plan 9 from User
Space's manual pages on a system using groff.
58 lines
1002 B
Groff
58 lines
1002 B
Groff
.TH SENDFD 3
|
|
.SH NAME
|
|
sendfd, recvfd \- pass file descriptors along Unix domain sockets
|
|
.SH SYNOPSIS
|
|
.B
|
|
#include <u.h>
|
|
.PP
|
|
.B
|
|
#include <libc.h>
|
|
.PP
|
|
.B
|
|
int sendfd(int socket, int fd)
|
|
.PP
|
|
.B
|
|
int recvfd(int socket)
|
|
.SH DESCRIPTION
|
|
.I Recvfd
|
|
and
|
|
.I sendfd
|
|
can be used to pass an open file descriptor over
|
|
a Unix domain socket from one process to another.
|
|
Since
|
|
.MR pipe 3
|
|
is implemented with
|
|
.MR socketpair 2
|
|
instead of
|
|
.MR pipe 2 ,
|
|
.I socket
|
|
can be a file descriptor obtained from
|
|
.MR pipe 3 .
|
|
.PP
|
|
.I Sendfd
|
|
sends the file descriptor
|
|
.I fd
|
|
along the socket to a process calling
|
|
.I recvfd
|
|
on the other end.
|
|
.PP
|
|
It is assumed that the two sides have coordinated
|
|
and agreed to transfer a file descriptor already, so
|
|
that the
|
|
.I sendfd
|
|
is met with a
|
|
.I recvfd
|
|
instead of an ordinary
|
|
.IR read .
|
|
.PP
|
|
The file descriptor number may change on its way
|
|
between processes, but the kernel structure it represents
|
|
will not.
|
|
.SH SOURCE
|
|
.B \*9/src/lib9/sendfd.c
|
|
.SH SEE ALSO
|
|
.MR socketpair 2 ,
|
|
.I sendmsg
|
|
in
|
|
.MR send 2
|