1 <?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
6 SPDX-License-Identifier: LGPL-2.1+
8 This file is part of elogind.
10 Copyright 2017 Lennart Poettering
13 <refentry id="sd_bus_is_open">
16 <title>sd_bus_is_open</title>
17 <productname>elogind</productname>
21 <contrib>Developer</contrib>
22 <firstname>Lennart</firstname>
23 <surname>Poettering</surname>
24 <email>lennart@poettering.net</email>
30 <refentrytitle>sd_bus_is_open</refentrytitle>
31 <manvolnum>3</manvolnum>
35 <refname>sd_bus_is_open</refname>
36 <refname>sd_bus_is_ready</refname>
38 <refpurpose>Check whether the a bus connection is open or ready.</refpurpose>
43 <funcsynopsisinfo>#include <elogind/sd-bus.h></funcsynopsisinfo>
46 <funcdef>int <function>sd_bus_is_open</function></funcdef>
47 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
51 <funcdef>int <function>sd_bus_is_ready</function></funcdef>
52 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
59 <title>Description</title>
61 <para><function>sd_bus_is_open()</function> checks whether the specified bus connection is open, i.e. in the
62 process of being established, already established or in the process of being torn down. It returns zero when the
63 connection has not been started yet
64 (i.e. <citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry> or some
65 equivalent call has not been invoked yet), or is fully terminated again (for example after
66 <citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>), it returns
67 positive otherwise.</para>
69 <para><function>sd_bus_is_ready()</function> checks whether the specified connection is fully established,
70 i.e. completed the connection and authentication phases of the protocol and received the
71 <function>Hello()</function> method call response, and is not in the process of being torn down again. It returns
72 zero outside of this state, and positive otherwise. Effectively, this function returns positive while regular
73 messages can be sent or received on the connection.</para>
75 <para>To be notified when the connection is fully established, use
76 <citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
77 install a match for the <function>Connected()</function> signal on the
78 <literal>org.freedesktop.DBus.Local</literal> interface. To be notified when the connection is torn down again,
79 install a match for the <function>Disconnected()</function> signal on the
80 <literal>org.freedesktop.DBus.Local</literal> interface.</para>
84 <title>Return Value</title>
86 <para>On success, these functions return 0 or a positive integer. On failure, they return a negative errno-style
93 <para>Returned errors may indicate the following problems:</para>
97 <term><constant>-ECHILD</constant></term>
99 <listitem><para>The bus connection has been created in a different process.</para></listitem>
107 <para><function>sd_bus_is_open()</function> and <function>sd_bus_is_ready()</function> are available as
108 a shared library, which can be compiled and linked to with the <constant>libelogind</constant> <citerefentry
109 project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry> file.</para>
113 <title>See Also</title>
116 <citerefentry><refentrytitle>elogind</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
117 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
118 <citerefentry><refentrytitle>sd_bus_start</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
119 <citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
120 <citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>