]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_bus_start.xml
test: make coverage runs happy with capsule@.service
[thirdparty/systemd.git] / man / sd_bus_start.xml
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.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="sd_bus_start"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>sd_bus_start</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>sd_bus_start</refentrytitle>
16 <manvolnum>3</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>sd_bus_start</refname>
21
22 <refpurpose>Initiate a bus connection to the D-bus broker daemon
23 </refpurpose>
24 </refnamediv>
25
26 <refsynopsisdiv>
27 <funcsynopsis>
28 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
29
30 <funcprototype>
31 <funcdef>int <function>sd_bus_start</function></funcdef>
32 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
33 </funcprototype>
34 </funcsynopsis>
35 </refsynopsisdiv>
36
37 <refsect1>
38 <title>Description</title>
39
40 <para><function>sd_bus_start()</function> connects an existing bus connection object to the D-Bus
41 broker daemon, usually
42 <citerefentry project='die-net'><refentrytitle>dbus-daemon</refentrytitle><manvolnum>1</manvolnum></citerefentry>
43 or
44 <citerefentry project='mankier'><refentrytitle>dbus-broker</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
45 The mechanism to use for the connection must be configured before the call to
46 <function>sd_bus_start()</function>, using one of
47 <citerefentry><refentrytitle>sd_bus_set_address</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
48 <citerefentry><refentrytitle>sd_bus_set_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>, or
49 <citerefentry><refentrytitle>sd_bus_set_exec</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
50 <function>sd_bus_start()</function> will open the connection socket or spawn the executable as
51 needed, and asynchronously start a <function>org.freedesktop.DBus.Hello()</function> call. The
52 answer to the Hello call will be processed later from
53 <citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry>. If
54 opening of the connection or queuing of the asynchronous call fail, the connection will be closed with
55 <citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
56
57 <para>In most cases, it is better to use
58 <citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
59 <citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>
60 or related calls instead of the more low-level <function>sd_bus_new()</function> and
61 <function>sd_bus_start()</function>. The higher-level functions not only allocate a bus object but also
62 start the connection to a well-known bus in a single function call.</para>
63 </refsect1>
64
65 <refsect1>
66 <title>Return Value</title>
67
68 <para>On success, this function returns a non-negative integer. On failure, it returns a negative
69 errno-style error code.</para>
70
71 <refsect2 id='errors'>
72 <title>Errors</title>
73
74 <variablelist>
75 <varlistentry>
76 <term><constant>-EINVAL</constant></term>
77
78 <listitem><para>The input parameter <parameter>bus</parameter> is <constant>NULL</constant>.
79 </para>
80
81 <xi:include href="version-info.xml" xpointer="v246"/></listitem>
82 </varlistentry>
83
84 <varlistentry>
85 <term><constant>-ENOPKG</constant></term>
86
87 <listitem><para>Bus object <parameter>bus</parameter> could not be resolved.</para>
88
89 <xi:include href="version-info.xml" xpointer="v246"/>
90 </listitem>
91 </varlistentry>
92
93 <varlistentry>
94 <term><constant>-EPERM</constant></term>
95
96 <listitem><para>The input parameter <parameter>bus</parameter> is in a wrong state
97 (<function>sd_bus_start()</function> may only be called once on a newly-created bus object).</para>
98
99 <xi:include href="version-info.xml" xpointer="v246"/>
100 </listitem>
101 </varlistentry>
102
103 <varlistentry>
104 <term><constant>-ECHILD</constant></term>
105
106 <listitem><para>The bus object <parameter>bus</parameter> was created in a different
107 process.</para>
108
109 <xi:include href="version-info.xml" xpointer="v246"/>
110 </listitem>
111 </varlistentry>
112 </variablelist>
113
114 <para>In addition, other connection-related errors may be returned. See
115 <citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
116 </refsect2>
117 </refsect1>
118
119 <xi:include href="libsystemd-pkgconfig.xml" />
120
121 <refsect1>
122 <title>History</title>
123 <para><function>sd_bus_start()</function> was added in version 246.</para>
124 </refsect1>
125
126 <refsect1>
127 <title>See Also</title>
128
129 <para><simplelist type="inline">
130 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
131 <member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
132 <member><citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
133 <member><citerefentry><refentrytitle>sd_bus_call_async</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
134 </simplelist></para>
135 </refsect1>
136
137 </refentry>