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-or-later -->
6 <refentry id="sd_bus_set_close_on_exit"
7 xmlns:xi="http://www.w3.org/2001/XInclude">
10 <title>sd_bus_set_close_on_exit</title>
11 <productname>systemd</productname>
15 <refentrytitle>sd_bus_set_close_on_exit</refentrytitle>
16 <manvolnum>3</manvolnum>
20 <refname>sd_bus_set_close_on_exit</refname>
21 <refname>sd_bus_get_close_on_exit</refname>
23 <refpurpose>Control whether to close the bus connection during the event loop exit phase
29 <funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo>
32 <funcdef>int <function>sd_bus_set_close_on_exit</function></funcdef>
33 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
34 <paramdef>int <parameter>b</parameter></paramdef>
38 <funcdef>int <function>sd_bus_get_close_on_exit</function></funcdef>
39 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
46 <title>Description</title>
48 <para><function>sd_bus_set_close_on_exit()</function> may be used to enable or disable whether
49 the bus connection is automatically flushed (as in
50 <citerefentry><refentrytitle>sd_bus_flush</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
52 <citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
53 during the exit phase of the event loop. This logic only applies to bus connections that are
55 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
57 <citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
58 By default this mechanism is enabled and makes sure that any pending messages that have not been
59 written to the bus connection are written out when the event loop is shutting down. In some
60 cases this behaviour is not desirable, for example when the bus connection shall remain usable
61 until after the event loop exited. If <parameter>b</parameter> is true, the feature is enabled
62 (which is the default), otherwise disabled.</para>
64 <para><function>sd_bus_get_close_on_exit()</function> may be used to query the current setting
65 of this feature. It returns zero when the feature is disabled, and positive if enabled.</para>
69 <title>Return Value</title>
71 <para>On success, <function>sd_bus_set_close_on_exit()</function> returns a non-negative
72 integer. On failure, it returns a negative errno-style error code.</para>
74 <para><function>sd_bus_get_close_on_exit()</function> returns 0 if the feature is currently
75 disabled or a positive integer if it is enabled. On failure, it returns a negative errno-style
81 <para>Returned errors may indicate the following problems:</para>
85 <term><constant>-ECHILD</constant></term>
87 <listitem><para>The bus connection was created in a different process, library or module instance.</para>
94 <xi:include href="libsystemd-pkgconfig.xml" />
97 <title>History</title>
98 <para><function>sd_bus_set_close_on_exit()</function> and
99 <function>sd_bus_get_close_on_exit()</function> were added in version 240.</para>
103 <title>See Also</title>
106 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
107 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
108 <citerefentry><refentrytitle>sd_bus_flush</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
109 <citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
110 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
111 <citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>