| 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.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="sd_bus_set_close_on_exit" |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
|
| 9 |
<refentryinfo> |
| 10 |
<title>sd_bus_set_close_on_exit</title> |
| 11 |
<productname>systemd</productname> |
| 12 |
</refentryinfo> |
| 13 |
|
| 14 |
<refmeta> |
| 15 |
<refentrytitle>sd_bus_set_close_on_exit</refentrytitle> |
| 16 |
<manvolnum>3</manvolnum> |
| 17 |
</refmeta> |
| 18 |
|
| 19 |
<refnamediv> |
| 20 |
<refname>sd_bus_set_close_on_exit</refname> |
| 21 |
<refname>sd_bus_get_close_on_exit</refname> |
| 22 |
|
| 23 |
<refpurpose>Control whether to close the bus connection during the event loop exit phase |
| 24 |
</refpurpose> |
| 25 |
</refnamediv> |
| 26 |
|
| 27 |
<refsynopsisdiv> |
| 28 |
<funcsynopsis> |
| 29 |
<funcsynopsisinfo>#include <systemd/sd-bus.h></funcsynopsisinfo> |
| 30 |
|
| 31 |
<funcprototype> |
| 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> |
| 35 |
</funcprototype> |
| 36 |
|
| 37 |
<funcprototype> |
| 38 |
<funcdef>int <function>sd_bus_get_close_on_exit</function></funcdef> |
| 39 |
<paramdef>sd_bus *<parameter>bus</parameter></paramdef> |
| 40 |
</funcprototype> |
| 41 |
|
| 42 |
</funcsynopsis> |
| 43 |
</refsynopsisdiv> |
| 44 |
|
| 45 |
<refsect1> |
| 46 |
<title>Description</title> |
| 47 |
|
| 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>) |
| 51 |
and closed (as in |
| 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 |
| 54 |
attached to an |
| 55 |
<citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry> |
| 56 |
event loop, see |
| 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> |
| 63 |
|
| 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> |
| 66 |
</refsect1> |
| 67 |
|
| 68 |
<refsect1> |
| 69 |
<title>Return Value</title> |
| 70 |
|
| 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> |
| 73 |
|
| 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 |
| 76 |
error code.</para> |
| 77 |
|
| 78 |
<refsect2> |
| 79 |
<title>Errors</title> |
| 80 |
|
| 81 |
<para>Returned errors may indicate the following problems:</para> |
| 82 |
|
| 83 |
<variablelist> |
| 84 |
<varlistentry> |
| 85 |
<term><constant>-ECHILD</constant></term> |
| 86 |
|
| 87 |
<listitem><para>The bus connection was created in a different process, library or module instance.</para> |
| 88 |
</listitem> |
| 89 |
</varlistentry> |
| 90 |
</variablelist> |
| 91 |
</refsect2> |
| 92 |
</refsect1> |
| 93 |
|
| 94 |
<xi:include href="libsystemd-pkgconfig.xml" /> |
| 95 |
|
| 96 |
<refsect1> |
| 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> |
| 100 |
</refsect1> |
| 101 |
|
| 102 |
<refsect1> |
| 103 |
<title>See Also</title> |
| 104 |
|
| 105 |
<para><simplelist type="inline"> |
| 106 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 107 |
<member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 108 |
<member><citerefentry><refentrytitle>sd_bus_flush</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 109 |
<member><citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 110 |
<member><citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 111 |
<member><citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 112 |
</simplelist></para> |
| 113 |
</refsect1> |
| 114 |
</refentry> |