1:255.16-alt1
[systemd_ALT.git] / man / sd_bus_set_watch_bind.xml
blob02e5f8f7d9e7d6848fb3a4a8ef1b520c3aef4560
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 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id="sd_bus_set_watch_bind"
7           xmlns:xi="http://www.w3.org/2001/XInclude">
9   <refentryinfo>
10     <title>sd_bus_set_watch_bind</title>
11     <productname>systemd</productname>
12   </refentryinfo>
14   <refmeta>
15     <refentrytitle>sd_bus_set_watch_bind</refentrytitle>
16     <manvolnum>3</manvolnum>
17   </refmeta>
19   <refnamediv>
20     <refname>sd_bus_set_watch_bind</refname>
21     <refname>sd_bus_get_watch_bind</refname>
23     <refpurpose>Control socket binding watching on bus connections</refpurpose>
24   </refnamediv>
26   <refsynopsisdiv>
27     <funcsynopsis>
28       <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
30       <funcprototype>
31         <funcdef>int <function>sd_bus_set_watch_bind</function></funcdef>
32         <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
33         <paramdef>int <parameter>b</parameter></paramdef>
34       </funcprototype>
36       <funcprototype>
37         <funcdef>int <function>sd_bus_get_watch_bind</function></funcdef>
38         <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
39       </funcprototype>
41     </funcsynopsis>
42   </refsynopsisdiv>
44   <refsect1>
45     <title>Description</title>
47     <para><function>sd_bus_set_watch_bind()</function> may be used to enable or disable client-side watching of server
48     socket binding for a bus connection object. If the <parameter>b</parameter> is true, the feature is enabled,
49     otherwise disabled (which is the default). When enabled, and the selected bus address refers to an
50     <filename>AF_UNIX</filename> socket in the file system which does not exist while the connection attempt is made an
51     <citerefentry project='man-pages'><refentrytitle>inotify</refentrytitle><manvolnum>7</manvolnum></citerefentry> watch is installed on
52     it, waiting for the socket to appear. As soon as the socket appears the connection is made. This functionality is
53     useful in particular in early-boot programs that need to run before the system bus is available, but want to
54     connect to it the instant it may be connected to.</para>
56     <para><function>sd_bus_get_watch_bind()</function> may be used to query the current setting of this feature. It
57     returns zero when the feature is disabled, and positive if enabled.</para>
59     <para>Note that no timeout is applied while we wait for the socket to appear. This means that any
60     synchronous remote operation (such as
61     <citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
62     <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry> or
63     <citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>),
64     that is used on a connection with this feature enabled that hasn't been established yet, might block
65     forever if the socket is never created. However, asynchronous remote operations (such as
66     <citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
67     <citerefentry><refentrytitle>sd_bus_call_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
68     <citerefentry><refentrytitle>sd_bus_add_match_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
69     do not block in this case, and safely enqueue the requested operations to be dispatched the instant the
70     connection is set up.</para>
72     <para>Use <citerefentry><refentrytitle>sd_bus_is_ready</refentrytitle><manvolnum>3</manvolnum></citerefentry> to
73     determine whether the connection is fully established, i.e. whether the peer socket has been bound, connected to
74     and authenticated. Use
75     <citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry> to
76     be notified when the connection is fully established.</para>
78   </refsect1>
80   <refsect1>
81     <title>Return Value</title>
83     <para>On success, these functions return 0 or a positive integer. On failure, they return a negative
84     errno-style error code.</para>
86     <refsect2>
87       <title>Errors</title>
89       <para>Returned errors may indicate the following problems:</para>
91       <variablelist>
92         <varlistentry>
93           <term><constant>-ECHILD</constant></term>
95           <listitem><para>The bus connection has been created in a different process, library or module instance.</para></listitem>
96         </varlistentry>
97       </variablelist>
98     </refsect2>
99   </refsect1>
101   <xi:include href="libsystemd-pkgconfig.xml" />
103   <refsect1>
104     <title>Example</title>
106     <example>
107       <title>Create a simple system service that publishes a property on the system bus and can reconnect
108       when D-Bus disconnects and reconnects</title>
110       <programlisting><xi:include href="sd_bus_service_reconnect.c" parse="text"/></programlisting>
112       <para>This is particularly useful for services that are configured to survive a soft-reboot, see
113       <citerefentry><refentrytitle>systemd-soft-reboot.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>
114       for more details.</para>
115     </example>
116   </refsect1>
118   <refsect1>
119     <title>History</title>
120     <para><function>sd_bus_set_watch_bind()</function> and
121     <function>sd_bus_get_watch_bind()</function> were added in version 237.</para>
122   </refsect1>
124   <refsect1>
125     <title>See Also</title>
127     <para>
128       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
129       <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
130       <citerefentry project='man-pages'><refentrytitle>inotify</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
131       <citerefentry><refentrytitle>sd_bus_call</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
132       <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
133       <citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
134       <citerefentry><refentrytitle>sd_bus_is_ready</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
135       <citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>
136     </para>
137   </refsect1>
139 </refentry>