]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_bus_close.xml
man: fix link markup
[thirdparty/systemd.git] / man / sd_bus_close.xml
CommitLineData
576af73f 1<?xml version='1.0'?>
3a54a157
ZJS
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
0307f791 4<!-- SPDX-License-Identifier: LGPL-2.1+ -->
576af73f
LP
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>
9783b59b 22 <refname>sd_bus_default_flush_close</refname>
576af73f
LP
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>
9783b59b
ZJS
40
41 <funcprototype>
42 <funcdef>void <function>sd_bus_default_flush_close</function></funcdef>
43 <paramdef>void</paramdef>
44 </funcprototype>
576af73f
LP
45 </funcsynopsis>
46 </refsynopsisdiv>
47
48 <refsect1>
49 <title>Description</title>
50
535f1d04
DDM
51 <para><function>sd_bus_close()</function> disconnects the specified bus connection. When this
52 call is invoked and the specified bus object refers to an active connection it is immediately
53 terminated. No further messages may be sent or received on it. Any messages queued in the bus
54 object (both incoming and outgoing) are released. If invoked on <constant>NULL</constant> bus
55 object or when the bus connection is already closed this function executes no operation. This
56 call does not free or unreference the bus object itself. Use
57 <citerefentry><refentrytitle>sd_bus_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>
58 for that.</para>
59
60 <para><function>sd_bus_flush()</function> synchronously writes out all outgoing queued message
61 on a bus connection if there are any. This function call may block if the peer is not processing
62 bus messages quickly.</para>
576af73f
LP
63
64 <para>Before a program exits it is usually a good idea to flush any pending messages with
535f1d04
DDM
65 <function>sd_bus_flush()</function> and then close connections with
66 <function>sd_bus_close()</function> to ensure that no unwritten messages are lost, no further
67 messages may be queued and all incoming but unprocessed messages are released. After both
68 operations have been done, it is a good idea to also drop any remaining references to the bus
69 object so that it may be freed. Since these three operations are frequently done together a
70 helper call
71 <citerefentry><refentrytitle>sd_bus_flush_close_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>
72 is provided that combines them into one.</para>
9783b59b
ZJS
73
74 <para><function>sd_bus_default_flush_close()</function> is similar to
535f1d04 75 <function>sd_bus_flush_close_unref</function>, but does not take a bus pointer argument and
15dd4515 76 instead iterates over any of the "default" buses opened by
9783b59b
ZJS
77 <citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
78 <citerefentry><refentrytitle>sd_bus_default_user</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
79 <citerefentry><refentrytitle>sd_bus_default_system</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
535f1d04 80 and similar calls. <function>sd_bus_default_flush_close()</function> is particularly useful to
15dd4515 81 clean up any buses opened using those calls before the program exits.</para>
576af73f
LP
82 </refsect1>
83
84 <refsect1>
85 <title>Return Value</title>
86
535f1d04
DDM
87 <para>On success, <function>sd_bus_flush()</function> returns a non-negative integer. On
88 failure, it returns a negative errno-style error code.</para>
576af73f 89
b1de39de
ZJS
90 <refsect2>
91 <title>Errors</title>
576af73f 92
b1de39de 93 <para>Returned errors may indicate the following problems:</para>
576af73f 94
b1de39de
ZJS
95 <variablelist>
96 <varlistentry>
97 <term><constant>-ECHILD</constant></term>
576af73f 98
535f1d04
DDM
99 <listitem><para>The bus connection has been created in a different process.</para>
100 </listitem>
b1de39de
ZJS
101 </varlistentry>
102 </variablelist>
103 </refsect2>
576af73f
LP
104 </refsect1>
105
106 <xi:include href="libsystemd-pkgconfig.xml" />
107
108 <refsect1>
109 <title>See Also</title>
110
111 <para>
112 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
113 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
114 <citerefentry><refentrytitle>sd_bus_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
115 <citerefentry><refentrytitle>sd_bus_set_close_on_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>
116 </para>
117 </refsect1>
118
119</refentry>