1 <?xml version='
1.0'
?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5 <!-- SPDX-License-Identifier: LGPL-2.1+ -->
7 <refentry id=
"sd_bus_slot_set_floating">
10 <title>sd_bus_slot_set_floating
</title>
11 <productname>systemd
</productname>
15 <refentrytitle>sd_bus_slot_set_floating
</refentrytitle>
16 <manvolnum>3</manvolnum>
20 <refname>sd_bus_slot_set_floating
</refname>
21 <refname>sd_bus_slot_get_floating
</refname>
23 <refpurpose>Control whether a bus slot object is
"floating".
</refpurpose>
28 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
31 <funcdef>int
<function>sd_bus_slot_set_floating
</function></funcdef>
32 <paramdef>sd_bus_slot *
<parameter>bus
</parameter></paramdef>
33 <paramdef>int
<parameter>b
</parameter></paramdef>
37 <funcdef>int
<function>sd_bus_slot_get_floating
</function></funcdef>
38 <paramdef>sd_bus_slot *
<parameter>slot
</parameter></paramdef>
45 <title>Description
</title>
47 <para><function>sd_bus_slot_set_floating()
</function> controls whether the specified bus slot object
48 <parameter>slot
</parameter> shall be
"floating" or not. A floating bus slot object's lifetime is bound to the
49 lifetime of the bus object it is associated with, meaning that it remains allocated as long as the bus object
50 itself and is freed automatically when the bus object is freed. Regular (i.e. non-floating) bus slot objects keep
51 the bus referenced, hence the bus object remains allocated at least as long as there remains at least one
52 referenced bus slot object around. The floating state hence controls the direction of referencing between the bus
53 object and the bus slot objects: if floating the bus pins the the bus slot, and otherwise the bus slot pins the bus
54 objects. Use
<function>sd_bus_slot_set_floating()
</function> to switch between both modes: if the
55 <parameter>b
</parameter> parameter is zero, the slot object is considered floating, otherwise it is made a regular
56 (non-floating) slot object.
</para>
58 <para>Bus slot objects may be allocated with calls such as
59 <citerefentry><refentrytitle>sd_bus_add_match
</refentrytitle><manvolnum>3</manvolnum></citerefentry>. If the
60 <parameter>slot
</parameter> of these functions is non-
<constant>NULL
</constant> the slot object will be of the
61 regular kind (i.e. non-floating), otherwise it will be created floating. With
62 <function>sd_bus_slot_set_floating()
</function> a bus slot object allocated as regular can be converted into a
63 floating object and back. This is particularly useful for creating a bus slot object, then changing parameters of
64 it, and then turning it into a floating object, whose lifecycle is managed by the bus object.
</para>
66 <para><function>sd_bus_slot_get_floating()
</function> returns the current floating state of the specified bus slot
67 object. It returns negative on error, zero if the bus slot object is a regular (non-floating) object and positive
72 <title>Return Value
</title>
74 <para>On success, these functions return
0 or a positive integer. On failure, they return 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 has been created in a different process.
</para></listitem>
91 <term><constant>-ESTALE
</constant></term>
93 <listitem><para>The bus object the specified bus slot object is associated with has already been freed, and
94 hence no change in the floating state can be made anymore.
</para></listitem>
102 <para><function>sd_bus_slot_set_floating()
</function> and
<function>sd_bus_slot_get_floating()
</function> are
103 available as a shared library, which can be compiled and linked to with the
104 <constant>libsystemd
</constant> <citerefentry
105 project='die-net'
><refentrytitle>pkg-config
</refentrytitle><manvolnum>1</manvolnum></citerefentry> file.
</para>
109 <title>See Also
</title>
112 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
113 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
114 <citerefentry><refentrytitle>sd_bus_add_match
</refentrytitle><manvolnum>3</manvolnum></citerefentry>