2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1-or-later
8 Copyright © 2016 Julian Orth
11 <refentry id=
"sd_bus_set_fd" xmlns:
xi=
"http://www.w3.org/2001/XInclude">
14 <title>sd_bus_set_fd
</title>
15 <productname>systemd
</productname>
19 <refentrytitle>sd_bus_set_fd
</refentrytitle>
20 <manvolnum>3</manvolnum>
24 <refname>sd_bus_set_fd
</refname>
26 <refpurpose>Set the file descriptors to use for bus communication
</refpurpose>
31 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
34 <funcdef>int
<function>sd_bus_set_fd
</function></funcdef>
35 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
36 <paramdef>int
<parameter>input_fd
</parameter></paramdef>
37 <paramdef>int
<parameter>output_fd
</parameter></paramdef>
43 <title>Description
</title>
45 <para><function>sd_bus_set_fd()
</function> sets the file descriptors used to communicate by a bus
46 connection object. Both
<parameter>input_fd
</parameter> and
<parameter>output_fd
</parameter> must be
47 valid file descriptors, referring to stream-based file objects (e.g. a stream socket, a pair of pipes or
48 FIFOs, or even a TTY device).
<parameter>input_fd
</parameter> must be readable, and
49 <parameter>output_fd
</parameter> must be writable. The same file descriptor may be used (and typically is
50 used) as both the input and the output file descriptor. This function must be called before the bus
51 connection is started via
52 <citerefentry><refentrytitle>sd_bus_start
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
54 <para>The bus connection object will take possession of the passed file descriptors and will close them
55 automatically when it is freed. Use
56 <citerefentry><refentrytitle>sd_bus_set_close_on_exit
</refentrytitle><manvolnum>3</manvolnum></citerefentry>
57 to turn off this behaviour.
</para>
61 <title>Return Value
</title>
63 <para>On success,
<function>sd_bus_set_fd()
</function> returns a non-negative integer. On
64 failure, it returns a negative errno-style error code.
</para>
69 <para>Returned errors may indicate the following problems:
</para>
73 <term><constant>-EINVAL
</constant></term>
75 <listitem><para>An invalid bus object was passed.
</para>
77 <xi:include href=
"version-info.xml" xpointer=
"v248"/></listitem>
81 <term><constant>-ECHILD
</constant></term>
83 <listitem><para>The bus connection was allocated in a parent process and is being reused
84 in a child process after
<function>fork()
</function>.
</para>
86 <xi:include href=
"version-info.xml" xpointer=
"v248"/></listitem>
90 <term><constant>-EBADF
</constant></term>
92 <listitem><para>An invalid file descriptor was passed to
93 <function>sd_bus_set_fd()
</function>.
</para>
95 <xi:include href=
"version-info.xml" xpointer=
"v248"/></listitem>
99 <term><constant>-ENOPKG
</constant></term>
101 <listitem><para>The bus cannot be resolved.
</para>
103 <xi:include href=
"version-info.xml" xpointer=
"v248"/></listitem>
107 <term><constant>-EPERM
</constant></term>
109 <listitem><para>The bus connection has already been started.
</para>
111 <xi:include href=
"version-info.xml" xpointer=
"v248"/></listitem>
117 <xi:include href=
"libsystemd-pkgconfig.xml" />
120 <title>History
</title>
121 <para><function>sd_bus_set_fd()
</function> was added in version
248.
</para>
125 <title>See Also
</title>
128 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
129 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
130 <citerefentry><refentrytitle>sd_bus_get_fd
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
131 <citerefentry><refentrytitle>sd_bus_start
</refentrytitle><manvolnum>3</manvolnum></citerefentry>