1<?xml version='1.0'?> 2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" 3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> 4 5<!-- 6 SPDX-License-Identifier: LGPL-2.1-or-later 7 8 Copyright © 2016 Julian Orth 9--> 10 11<refentry id="sd_bus_set_fd" xmlns:xi="http://www.w3.org/2001/XInclude"> 12 13 <refentryinfo> 14 <title>sd_bus_set_fd</title> 15 <productname>systemd</productname> 16 </refentryinfo> 17 18 <refmeta> 19 <refentrytitle>sd_bus_set_fd</refentrytitle> 20 <manvolnum>3</manvolnum> 21 </refmeta> 22 23 <refnamediv> 24 <refname>sd_bus_set_fd</refname> 25 26 <refpurpose>Set the file descriptors to use for bus communication</refpurpose> 27 </refnamediv> 28 29 <refsynopsisdiv> 30 <funcsynopsis> 31 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> 32 33 <funcprototype> 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> 38 </funcprototype> 39 </funcsynopsis> 40 </refsynopsisdiv> 41 42 <refsect1> 43 <title>Description</title> 44 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> 53 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> 58 </refsect1> 59 60 <refsect1> 61 <title>Return Value</title> 62 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> 65 66 <refsect2> 67 <title>Errors</title> 68 69 <para>Returned errors may indicate the following problems:</para> 70 71 <variablelist> 72 <varlistentry> 73 <term><constant>-EINVAL</constant></term> 74 75 <listitem><para>An invalid bus object was passed.</para></listitem> 76 </varlistentry> 77 78 <varlistentry> 79 <term><constant>-ECHILD</constant></term> 80 81 <listitem><para>The bus connection was allocated in a parent process and is being reused 82 in a child process after <function>fork()</function>.</para></listitem> 83 </varlistentry> 84 85 <varlistentry> 86 <term><constant>-EBADF</constant></term> 87 88 <listitem><para>An invalid file descriptor was passed to 89 <function>sd_bus_set_fd()</function>.</para></listitem> 90 </varlistentry> 91 92 <varlistentry> 93 <term><constant>-ENOPKG</constant></term> 94 95 <listitem><para>The bus cannot be resolved.</para></listitem> 96 </varlistentry> 97 98 <varlistentry> 99 <term><constant>-EPERM</constant></term> 100 101 <listitem><para>The bus connection has already been started.</para></listitem> 102 </varlistentry> 103 </variablelist> 104 </refsect2> 105 </refsect1> 106 107 <xi:include href="libsystemd-pkgconfig.xml" /> 108 109 <refsect1> 110 <title>See Also</title> 111 112 <para> 113 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, 114 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 115 <citerefentry><refentrytitle>sd_bus_get_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>, 116 <citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry> 117 </para> 118 </refsect1> 119 120</refentry> 121