]>
Commit | Line | Data |
---|---|---|
6e866b33 | 1 | <?xml version='1.0'?> |
bb4f798a MB |
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+ --> | |
6e866b33 MB |
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 | ||
23 | <refpurpose>Close and flush a bus connection</refpurpose> | |
24 | </refnamediv> | |
25 | ||
26 | <refsynopsisdiv> | |
27 | <funcsynopsis> | |
28 | <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> | |
29 | ||
30 | <funcprototype> | |
31 | <funcdef>void <function>sd_bus_close</function></funcdef> | |
32 | <paramdef>sd_bus *<parameter>bus</parameter></paramdef> | |
33 | </funcprototype> | |
34 | ||
35 | <funcprototype> | |
36 | <funcdef>int <function>sd_bus_flush</function></funcdef> | |
37 | <paramdef>sd_bus *<parameter>bus</parameter></paramdef> | |
38 | </funcprototype> | |
39 | </funcsynopsis> | |
40 | </refsynopsisdiv> | |
41 | ||
42 | <refsect1> | |
43 | <title>Description</title> | |
44 | ||
45 | <para><function>sd_bus_close()</function> disconnects the specified bus connection. When this call is invoked and | |
46 | the specified bus object refers to an active connection it is immediately terminated. No further messages may be | |
47 | sent or receieved on it. Any messages queued in the bus object (both incoming and outgoing) are released. If | |
48 | invoked on <constant>NULL</constant> bus object or when the bus connection is already closed this function executes | |
49 | no operation. This call does not free or unreference the bus object itself. Use | |
50 | <citerefentry><refentrytitle>sd_bus_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry> for that.</para> | |
51 | ||
52 | <para><function>sd_bus_flush()</function> synchronously writes out all outgoing queued message on a bus connection | |
53 | if there are any. This function call may block if the peer is not processing bus messages quickly.</para> | |
54 | ||
55 | <para>Before a program exits it is usually a good idea to flush any pending messages with | |
56 | <function>sd_bus_flush()</function> and then close connections with <function>sd_bus_close()</function> to ensure | |
57 | that no unwritten messages are lost, no further messages may be queued and all incoming but unprocessed messages | |
58 | are released. After both operations have been done, it is a good idea to also drop any remaining references to the | |
59 | bus object so that it may be freed. Since these three operations are frequently done together a helper call | |
60 | <citerefentry><refentrytitle>sd_bus_flush_close_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry> is | |
61 | provided that combines them into one.</para> | |
62 | </refsect1> | |
63 | ||
64 | <refsect1> | |
65 | <title>Return Value</title> | |
66 | ||
67 | <para>On success, <function>sd_bus_flush()</function> returns 0 or a positive integer. On failure, it returns a | |
68 | negative errno-style error code.</para> | |
6e866b33 | 69 | |
bb4f798a MB |
70 | <refsect2> |
71 | <title>Errors</title> | |
6e866b33 | 72 | |
bb4f798a | 73 | <para>Returned errors may indicate the following problems:</para> |
6e866b33 | 74 | |
bb4f798a MB |
75 | <variablelist> |
76 | <varlistentry> | |
77 | <term><constant>-ECHILD</constant></term> | |
6e866b33 | 78 | |
bb4f798a MB |
79 | <listitem><para>The bus connection has been created in a different process.</para></listitem> |
80 | </varlistentry> | |
81 | </variablelist> | |
82 | </refsect2> | |
6e866b33 MB |
83 | </refsect1> |
84 | ||
85 | <xi:include href="libsystemd-pkgconfig.xml" /> | |
86 | ||
87 | <refsect1> | |
88 | <title>See Also</title> | |
89 | ||
90 | <para> | |
91 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
92 | <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
93 | <citerefentry><refentrytitle>sd_bus_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
94 | <citerefentry><refentrytitle>sd_bus_set_close_on_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
95 | </para> | |
96 | </refsect1> | |
97 | ||
98 | </refentry> |