Debian Codegraph @

upstream/debian-unstable/man3/sd_varlink_push_fd.3

raw
1 '\" t
2 .TH "SD_VARLINK_PUSH_FD" "3" "" "systemd 261~rc3" "sd_varlink_push_fd"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 sd_varlink_push_fd, sd_varlink_push_dup_fd \- Submit a file descriptor to send along with the next outgoing Varlink message
24 .SH "SYNOPSIS"
25 .sp
26 .ft B
27 .nf
28 #include <systemd/sd\-varlink\&.h>
29 .fi
30 .ft
31 .HP \w'int\ sd_varlink_push_fd('u
32 .BI "int sd_varlink_push_fd(sd_varlink\ *" "link" ", int\ " "fd" ");"
33 .HP \w'int\ sd_varlink_push_dup_fd('u
34 .BI "int sd_varlink_push_dup_fd(sd_varlink\ *" "link" ", int\ " "fd" ");"
35 .SH "DESCRIPTION"
36 .PP
37 \fBsd_varlink_push_fd()\fR
38 submits a file descriptor to send along with the next outgoing Varlink message\&. Takes a Varlink connection object and a file descriptor as parameter\&. The file descriptor is not duplicated, and hence ownership of the file descriptor is passed to the Varlink connection object (only on success; on failure the caller retains ownership)\&. Once the file descriptor has been written to the underlying transport socket it is automatically closed\&. The calling application code should not touch the file descriptor or close it on its own, otherwise it will interfere with the Varlink protocol implementation\&. This call is only supported if the backing transport supports file descriptor passing (effectively this means the functionality is supported on local
39 \fBAF_UNIX\fR
40 only), and the concept is not part of the Varlink protocol, but simply a feature of the underlying transport\&.
41 .PP
42 \fBsd_varlink_push_dup_fd()\fR
43 is identical to
44 \fBsd_varlink_push_fd()\fR, except that the file descriptor is duplicated automatically, and the calling application code hence retains ownership of the provided file descriptor, and must close it on its own\&.
45 .PP
46 Note that file descriptor passing is only permitted after a call to
47 \fBsd_varlink_set_allow_fd_passing_output()\fR
48 that enables it, otherwise these calls will fail with
49 \fB\-EPERM\fR\&.
50 .PP
51 Note that on Linux a maximum of 253 file descriptors may be enqueued on
52 \fBAF_UNIX\fR
53 sockets at once\&. Attempting to enqueue more on a single Varlink message will fail with
54 \fB\-ENOBUFS\fR\&.
55 .SH "RETURN VALUE"
56 .PP
57 On success,
58 \fBsd_varlink_push_fd()\fR
59 and
60 \fBsd_varlink_push_dup_fd()\fR
61 return a non\-negative integer\&. On failure, they return a negative errno\-style error code\&.
62 .SS "Errors"
63 .PP
64 Returned errors may indicate the following problems:
65 .PP
66 \fB\-EINVAL\fR
67 .RS 4
68 An argument is invalid\&.
69 .RE
70 .PP
71 \fB\-EBADF\fR
72 .RS 4
73 The provided file descriptor is not valid\&.
74 .RE
75 .PP
76 \fB\-EPERM\fR
77 .RS 4
78 File descriptor passing has not been enabled via
79 \fBsd_varlink_set_allow_fd_passing_output()\fR\&.
80 .RE
81 .PP
82 \fB\-ENOBUFS\fR
83 .RS 4
84 The maximum of 253 file descriptors have already been submitted for the next outgoing Varlink message, no further descriptors may be enqueued for this message\&.
85 .RE
86 .PP
87 \fB\-ENOMEM\fR
88 .RS 4
89 Memory allocation failed\&.
90 .RE
91 .SH "NOTES"
92 .PP
93 Functions described here are available as a shared library, which can be compiled against and linked to with the
94 \fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
95 file\&.
96 .PP
97 The code described here uses
98 \fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call
99 \fBsetenv\fR(3)
100 from a parallel thread\&. It is recommended to only do calls to
101 \fBsetenv()\fR
102 from an early phase of the program when no other threads have been started\&.
103 .SH "HISTORY"
104 .PP
105 \fBsd_varlink_push_fd()\fR
106 and
107 \fBsd_varlink_push_dup_fd()\fR
108 were added in version 257\&.
109 .SH "SEE ALSO"
110 .PP
111 \fBsystemd\fR(1), \fBsd-varlink\fR(3)