]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_bus_close.xml
Merge pull request #14338 from keszybz/functional-test-rework
[thirdparty/systemd.git] / man / sd_bus_close.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.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
5
6 <refentry id="sd_bus_close"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
8
9 <refentryinfo>
10 <title>sd_bus_close</title>
11 <productname>systemd</productname>
12 </refentryinfo>
13
14 <refmeta>
15 <refentrytitle>sd_bus_close</refentrytitle>
16 <manvolnum>3</manvolnum>
17 </refmeta>
18
19 <refnamediv>
20 <refname>sd_bus_close</refname>
21 <refname>sd_bus_flush</refname>
22 <refname>sd_bus_default_flush_close</refname>
23
24 <refpurpose>Close and flush a bus connection</refpurpose>
25 </refnamediv>
26
27 <refsynopsisdiv>
28 <funcsynopsis>
29 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
30
31 <funcprototype>
32 <funcdef>void <function>sd_bus_close</function></funcdef>
33 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
34 </funcprototype>
35
36 <funcprototype>
37 <funcdef>int <function>sd_bus_flush</function></funcdef>
38 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
39 </funcprototype>
40
41 <funcprototype>
42 <funcdef>void <function>sd_bus_default_flush_close</function></funcdef>
43 <paramdef>void</paramdef>
44 </funcprototype>
45 </funcsynopsis>
46 </refsynopsisdiv>
47
48 <refsect1>
49 <title>Description</title>
50
51 <para><function>sd_bus_close()</function> disconnects the specified bus connection. When this call is invoked and
52 the specified bus object refers to an active connection it is immediately terminated. No further messages may be
53 sent or received on it. Any messages queued in the bus object (both incoming and outgoing) are released. If
54 invoked on <constant>NULL</constant> bus object or when the bus connection is already closed this function executes
55 no operation. This call does not free or unreference the bus object itself. Use
56 <citerefentry><refentrytitle>sd_bus_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry> for that.</para>
57
58 <para><function>sd_bus_flush()</function> synchronously writes out all outgoing queued message on a bus connection
59 if there are any. This function call may block if the peer is not processing bus messages quickly.</para>
60
61 <para>Before a program exits it is usually a good idea to flush any pending messages with
62 <function>sd_bus_flush()</function> and then close connections with <function>sd_bus_close()</function> to ensure
63 that no unwritten messages are lost, no further messages may be queued and all incoming but unprocessed messages
64 are released. After both operations have been done, it is a good idea to also drop any remaining references to the
65 bus object so that it may be freed. Since these three operations are frequently done together a helper call
66 <citerefentry><refentrytitle>sd_bus_flush_close_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry> is
67 provided that combines them into one.</para>
68
69 <para><function>sd_bus_default_flush_close()</function> is similar to
70 <function>sd_bus_flush_close_unref</function>, but does not take a bus pointer argument and instead
71 iterates over any of the "default" busses opened by
72 <citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
73 <citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
74 <citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
75 and similar calls. <function>sd_bus_default_flush_close()</function> is particularly useful to clean up
76 any busses opened using those calls before the program exits.</para>
77 </refsect1>
78
79 <refsect1>
80 <title>Return Value</title>
81
82 <para>On success, <function>sd_bus_flush()</function> returns 0 or a positive integer. On failure, it returns a
83 negative errno-style error code.</para>
84
85 <refsect2>
86 <title>Errors</title>
87
88 <para>Returned errors may indicate the following problems:</para>
89
90 <variablelist>
91 <varlistentry>
92 <term><constant>-ECHILD</constant></term>
93
94 <listitem><para>The bus connection has been created in a different process.</para></listitem>
95 </varlistentry>
96 </variablelist>
97 </refsect2>
98 </refsect1>
99
100 <xi:include href="libsystemd-pkgconfig.xml" />
101
102 <refsect1>
103 <title>See Also</title>
104
105 <para>
106 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
107 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
108 <citerefentry><refentrytitle>sd_bus_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
109 <citerefentry><refentrytitle>sd_bus_set_close_on_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>
110 </para>
111 </refsect1>
112
113 </refentry>