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