1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-26 14:04:03 +03:00

Merge pull request #15502 from DaanDeMeyer/sd-bus-exit-on-disconnect-docs

sd-bus: Add sd_bus_get/set_exit_on_disconnect docs
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-04-21 09:23:16 +02:00 committed by GitHub
commit 55c0fbde8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 147 additions and 23 deletions

View File

@ -388,6 +388,7 @@ manpages = [
'sd_bus_set_anonymous',
'sd_bus_set_trusted'],
''],
['sd_bus_set_exit_on_disconnect', '3', ['sd_bus_get_exit_on_disconnect'], ''],
['sd_bus_set_method_call_timeout',
'3',
['sd_bus_get_method_call_timeout'],

View File

@ -77,6 +77,7 @@
<citerefentry><refentrytitle>sd_bus_get_current_message</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_current_slot</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_current_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_exit_on_disconnect</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_method_call_timeout</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_get_n_queued_read</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
@ -124,16 +125,17 @@
<citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_address</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_bus_client</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_close_on_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_description</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_exit_on_disconnect</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_method_call_timeout</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_property</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_propertyv</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_sender</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_bus_client</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_server</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_set_watch_bind</refentrytitle><manvolnum>3</manvolnum></citerefentry>
<citerefentry><refentrytitle>sd_bus_set_close_on_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_slot_get_current_handler</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_slot_get_current_message</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_slot_get_current_userdata</refentrytitle><manvolnum>3</manvolnum></citerefentry>,

View File

@ -20,7 +20,8 @@
<refname>sd_bus_set_close_on_exit</refname>
<refname>sd_bus_get_close_on_exit</refname>
<refpurpose>Control whether to close the bus connection during the event loop exit phase</refpurpose>
<refpurpose>Control whether to close the bus connection during the event loop exit phase
</refpurpose>
</refnamediv>
<refsynopsisdiv>
@ -44,30 +45,35 @@
<refsect1>
<title>Description</title>
<para><function>sd_bus_set_close_on_exit()</function> may be used to enable or disable whether the bus connection
is automatically flushed (as in
<citerefentry><refentrytitle>sd_bus_flush</refentrytitle><manvolnum>3</manvolnum></citerefentry>) and closed (as in
<citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>) during the exit
phase of the event loop. This logic only applies to bus connections that are attached to an
<citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry> event loop, see
<citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry>. By default
this mechanism is enabled and makes sure that any pending messages that have not been written to the bus connection
are written out when the event loop is shutting down. In some cases this behaviour is not desirable, for example
when the bus connection shall remain usable until after the event loop exited. If <parameter>b</parameter> is
true, the feature is enabled (which is the default), otherwise disabled.</para>
<para><function>sd_bus_set_close_on_exit()</function> may be used to enable or disable whether
the bus connection is automatically flushed (as in
<citerefentry><refentrytitle>sd_bus_flush</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
and closed (as in
<citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
during the exit phase of the event loop. This logic only applies to bus connections that are
attached to an
<citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
event loop, see
<citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
By default this mechanism is enabled and makes sure that any pending messages that have not been
written to the bus connection are written out when the event loop is shutting down. In some
cases this behaviour is not desirable, for example when the bus connection shall remain usable
until after the event loop exited. If <parameter>b</parameter> is true, the feature is enabled
(which is the default), otherwise disabled.</para>
<para><function>sd_bus_get_close_on_exit()</function> may be used to query the current setting of this feature. It
returns zero when the feature is disabled, and positive if enabled.</para>
<para><function>sd_bus_get_close_on_exit()</function> may be used to query the current setting
of this feature. It returns zero when the feature is disabled, and positive if enabled.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, <function>sd_bus_set_close_on_exit()</function> returns 0 or a positive integer. On failure, it returns a negative errno-style
error code.</para>
<para>On success, <function>sd_bus_set_close_on_exit()</function> returns a non-negative
integer. On failure, it returns a negative errno-style error code.</para>
<para><function>sd_bus_get_close_on_exit()</function> returns 0 if the feature is currently turned off or a
positive integer if it is on. On failure, it returns a negative errno-style error code.</para>
<para><function>sd_bus_get_close_on_exit()</function> returns 0 if the feature is currently
disabled or a positive integer if it is enabled. On failure, it returns a negative errno-style
error code.</para>
<refsect2>
<title>Errors</title>
@ -78,7 +84,8 @@
<varlistentry>
<term><constant>-ECHILD</constant></term>
<listitem><para>The bus connection has been created in a different process.</para></listitem>
<listitem><para>The bus connection was created in a different process.</para>
</listitem>
</varlistentry>
</variablelist>
</refsect2>
@ -98,5 +105,4 @@
<citerefentry><refentrytitle>sd_event_add_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -0,0 +1,114 @@
<?xml version='1.0'?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<!-- SPDX-License-Identifier: LGPL-2.1+ -->
<refentry id="sd_bus_set_exit_on_disconnect"
xmlns:xi="http://www.w3.org/2001/XInclude">
<refentryinfo>
<title>sd_bus_set_exit_on_disconnect</title>
<productname>systemd</productname>
</refentryinfo>
<refmeta>
<refentrytitle>sd_bus_set_exit_on_disconnect</refentrytitle>
<manvolnum>3</manvolnum>
</refmeta>
<refnamediv>
<refname>sd_bus_set_exit_on_disconnect</refname>
<refname>sd_bus_get_exit_on_disconnect</refname>
<refpurpose>Control the exit behavior when the bus object disconnects</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
<funcprototype>
<funcdef>int <function>sd_bus_set_exit_on_disconnect</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
<paramdef>int <parameter>b</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_bus_get_exit_on_disconnect</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para><function>sd_bus_set_exit_on_disconnect()</function> may be used to configure the exit
behavior when the given bus object disconnects. If <parameter>b</parameter> is zero, no special
logic is executed when the bus object disconnects. If <parameter>b</parameter> is non-zero, the
behavior on disconnect depends on whether the bus object is attached to an event loop or not. If
the bus object is attached to an event loop (see
<citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry>),
the event loop is closed when the bus object disconnects (as if calling
<citerefentry><refentrytitle>sd_event_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>).
Otherwise,
<citerefentry project='man-pages'><refentrytitle>exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>
is called. The exit code passed to <function>sd_event_exit()</function> and
<function>exit()</function> is <constant>EXIT_FAILURE</constant>. If the bus object has already
disconnected when enabling the exit behavior, the exit behavior is executed immediately. By
default, the exit behavior is disabled.</para>
<para><function>sd_bus_get_exit_on_disconnect()</function> returns whether the exit on
disconnect behavior is enabled for the given bus object.</para>
</refsect1>
<refsect1>
<title>Return Value</title>
<para>On success, <function>sd_bus_set_exit_on_disconnect()</function> returns a non-negative
integer. On failure, it returns a negative errno-style error code.</para>
<para><function>sd_bus_get_exit_on_disconnect()</function> returns a positive integer if the
exit on disconnect behavior is enabled. Otherwise, it returns zero.</para>
<refsect2>
<title>Errors</title>
<para>Returned errors may indicate the following problems:</para>
<variablelist>
<varlistentry>
<term><constant>-EINVAL</constant></term>
<listitem><para>A required parameter was <constant>NULL</constant>.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ENOPKG</constant></term>
<listitem><para>The bus object could not be resolved.</para></listitem>
</varlistentry>
<varlistentry>
<term><constant>-ECHILD</constant></term>
<listitem><para>The bus connection was created in a different process.</para></listitem>
</varlistentry>
</variablelist>
</refsect2>
</refsect1>
<xi:include href="libsystemd-pkgconfig.xml" />
<refsect1>
<title>See Also</title>
<para>
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_event_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para>
</refsect1>
</refentry>

View File

@ -110,7 +110,8 @@
a non-negative integer. On failure, they return a negative errno-style error code.</para>
<para><function>sd_bus_is_server()</function> and <function>sd_bus_is_bus_client()</function>
return 1 when the server or client mode is enabled, respectively. Otherwise, they return 0.
return a positive integer when the server or client mode is enabled, respectively. Otherwise,
they return zero.
</para>
<refsect2>