Commit | Line | Data |
---|---|---|
c4ccbbf9 MW |
1 | .\" -*-nroff-*- |
2 | .\" | |
3 | .\" Manual for file descriptor passing | |
4 | .\" | |
5 | .\" (c) 2003, 2005, 2007, 2009, 2024 Straylight/Edgeware | |
6 | .\" | |
7 | . | |
8 | .\"----- Licensing notice --------------------------------------------------- | |
9 | .\" | |
10 | .\" This file is part of the mLib utilities library. | |
11 | .\" | |
12 | .\" mLib is free software: you can redistribute it and/or modify it under | |
13 | .\" the terms of the GNU Library General Public License as published by | |
14 | .\" the Free Software Foundation; either version 2 of the License, or (at | |
15 | .\" your option) any later version. | |
16 | .\" | |
17 | .\" mLib is distributed in the hope that it will be useful, but WITHOUT | |
18 | .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
19 | .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | |
20 | .\" License for more details. | |
21 | .\" | |
22 | .\" You should have received a copy of the GNU Library General Public | |
23 | .\" License along with mLib. If not, write to the Free Software | |
24 | .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
25 | .\" USA. | |
26 | . | |
27 | .\"-------------------------------------------------------------------------- | |
28 | .so ../defs.man \" @@@PRE@@@ | |
29 | . | |
30 | .\"-------------------------------------------------------------------------- | |
31 | .TH fdpass 3mLib "28 November 2003" "Straylight/Edgeware" "mLib utilities library" | |
32 | .\" @fdpass_send | |
33 | .\" @fdpass_recv | |
34 | . | |
35 | .\"-------------------------------------------------------------------------- | |
36 | .SH NAME | |
37 | fdpass \- file descriptor passing | |
38 | . | |
39 | .\"-------------------------------------------------------------------------- | |
40 | .SH SYNOPSIS | |
41 | . | |
42 | .nf | |
43 | .B "#include <mLib/fdpass.h>" | |
44 | .PP | |
45 | .BI "ssize_t fdpass_send(int " sock ", int " fd ", const void *" p ", size_t " sz ); | |
46 | .BI "ssize_t fdpass_recv(int " sock ", int *" fd ", void *" p ", size_t " sz ); | |
47 | .fi | |
48 | . | |
49 | .\"-------------------------------------------------------------------------- | |
50 | .SH DESCRIPTION | |
51 | . | |
52 | The function | |
53 | .B fdpass_send | |
54 | sends the file descriptor | |
55 | .I fd | |
56 | as ancillary data attached to the buffer pointed to by | |
57 | .I p | |
58 | of length | |
59 | .I sz | |
60 | over the Unix-domain socket | |
61 | .IR sock . | |
62 | It returns the amount of data sent, or \-1 on error. For more details, | |
63 | see | |
64 | .BR sendmsg (2) | |
65 | and | |
66 | .BR unix (7). | |
67 | .PP | |
68 | The function | |
69 | .B fdpass_recv | |
70 | receives at most | |
71 | .I sz | |
72 | bytes of data into the buffer pointed to by | |
73 | .IR p , | |
74 | together with at most one file descriptor passed as ancillary data, | |
75 | which is written to the integer pointed to by | |
76 | .IR fd . | |
77 | Other file descriptors received are closed; any other ancillary messages | |
78 | are ignored. If no file descriptor is received, | |
79 | .BI * fd | |
80 | is set to \-1. The function returns the number of bytes read, or \-1 on | |
81 | error. For more details, see | |
82 | .BR recvmsg (2) | |
83 | and | |
84 | .BR unix (7). | |
85 | . | |
86 | .\"-------------------------------------------------------------------------- | |
87 | .SH "SEE ALSO" | |
88 | . | |
89 | .BR recvmsg (2), | |
90 | .BR sendmsg (2), | |
91 | .BR mLib (3), | |
92 | .BR unix (7). | |
93 | . | |
94 | .\"-------------------------------------------------------------------------- | |
95 | .SH AUTHOR | |
96 | . | |
97 | Mark Wooding, <mdw@distorted.org.uk> | |
98 | . | |
99 | .\"----- That's all, folks -------------------------------------------------- |