aboutsummaryrefslogtreecommitdiff
path: root/man/man3/sendfd.3
blob: 771bd9ae59d3624fb6884076a9e8072fd4bd80bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
.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
.IR pipe (3)
is implemented with
.IR socketpair (2)
instead of
.IR pipe (2),
.I socket
can be a file descriptor obtained from
.IR 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
.IR socketpair (2),
.I sendmsg
in
.IR send (2)