1 <?xml version='
1.0'
?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % entities SYSTEM
"custom-entities.ent" >
9 This file is part of systemd.
11 Copyright 2013 Lennart Poettering
13 systemd is free software; you can redistribute it and/or modify it
14 under the terms of the GNU Lesser General Public License as published by
15 the Free Software Foundation; either version 2.1 of the License, or
16 (at your option) any later version.
18 systemd is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
23 You should have received a copy of the GNU Lesser General Public License
24 along with systemd; If not, see <http://www.gnu.org/licenses/>.
27 <refentry id=
"sd_bus_request_name">
30 <title>sd_bus_request_name
</title>
31 <productname>systemd
</productname>
35 <contrib>Developer
</contrib>
36 <firstname>Lennart
</firstname>
37 <surname>Poettering
</surname>
38 <email>lennart@poettering.net
</email>
44 <refentrytitle>sd_bus_request_name
</refentrytitle>
45 <manvolnum>3</manvolnum>
49 <refname>sd_bus_request_name
</refname>
50 <refname>sd_bus_release_name
</refname>
51 <refpurpose>Request or release a well-known name on a bus
</refpurpose>
56 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
59 <funcdef>int
<function>sd_bus_request_name
</function></funcdef>
60 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
61 <paramdef>const char *
<parameter>name
</parameter></paramdef>
62 <paramdef>uint64_t
<parameter>flags
</parameter></paramdef>
66 <funcdef>int
<function>sd_bus_release_name
</function></funcdef>
67 <paramdef>sd_bus *
<parameter>bus
</parameter></paramdef>
68 <paramdef>const char *
<parameter>name
</parameter></paramdef>
74 <title>Description
</title>
76 <para><function>sd_bus_request_name()
</function> requests a
77 well-known name on a bus. It takes a bus connection, a valid bus
78 name and a flags parameter. The flags parameter is a combination
79 of the following flags:
</para>
83 <term><varname>SD_BUS_NAME_ALLOW_REPLACEMENT
</varname></term>
85 <listitem><para>After acquiring the name successfully, permit
86 other peers to take over the name when they try to acquire it
87 with the
<varname>SD_BUS_NAME_REPLACE_EXISTING
</varname> flag
88 set. If
<varname>SD_BUS_NAME_ALLOW_REPLACEMENT
</varname> is
89 not set on the original request, such a request by other peers
90 will be denied.
</para></listitem>
94 <term><varname>SD_BUS_NAME_REPLACE_EXISTING
</varname></term>
96 <listitem><para>Take over the name if it is already acquired
97 by another peer, and that other peer has permitted takeover by
98 setting
<varname>SD_BUS_NAME_ALLOW_REPLACEMENT
</varname> while
99 acquiring it.
</para></listitem>
103 <term><varname>SD_BUS_NAME_QUEUE
</varname></term>
105 <listitem><para>Queue the acquisition of the name when the
106 name is already taken.
</para></listitem>
110 <para><function>sd_bus_release_name()
</function> releases an
111 acquired well-known name. It takes a bus connection and a valid
112 bus name as parameters.
</para>
116 <title>Return Value
</title>
118 <para>On success, these calls return
0 or a positive integer. On
119 failure, these calls return a negative errno-style error
122 <para>If
<varname>SD_BUS_NAME_QUEUE
</varname> is specified,
123 <function>sd_bus_request_name()
</function> will return
0 when the
124 name is already taken by another peer and the client has been
125 added to the queue for the name. In that case, the caller can
126 subscribe to
<literal>NameOwnerChanged
</literal> signals to be
127 notified when the name is successfully acquired.
128 <function>sd_bus_request_name()
</function> returns
> 0 when the
129 name has immediately been acquired successfully.
</para>
133 <title>Errors
</title>
135 <para>Returned errors may indicate the following problems:
</para>
139 <term><constant>-EALREADY
</constant></term>
141 <listitem><para>The caller already is the owner of the
142 specified name.
</para></listitem>
146 <term><constant>-EEXIST
</constant></term>
148 <listitem><para>The name has already been acquired by a
149 different peer, and SD_BUS_NAME_REPLACE_EXISTING was not
150 specified or the other peer did not specify
151 SD_BUS_NAME_ALLOW_REPLACEMENT while acquiring the
152 name.
</para></listitem>
156 <term><constant>-ESRCH
</constant></term>
158 <listitem><para>It was attempted to release a name that is
159 currently not registered on the bus.
</para></listitem>
163 <term><constant>-EADDRINUSE
</constant></term>
165 <listitem><para>It was attempted to release a name that is
166 owned by a different peer on the bus.
</para></listitem>
170 <term><constant>-EINVAL
</constant></term>
172 <listitem><para>A specified parameter is
173 invalid.
</para></listitem>
177 <term><constant>-ENOTCONN
</constant></term>
179 <listitem><para>The bus connection has been
180 disconnected.
</para></listitem>
184 <term><constant>-ECHILD
</constant></term>
186 <listitem><para>The bus connection has been created in a
187 different process than the current one.
</para></listitem>
195 <para>The
<function>sd_bus_acquire_name()
</function> and
196 <function>sd_bus_release_name()
</function> interfaces are
197 available as a shared library, which can be compiled and linked to
199 <constant>libsystemd
</constant> <citerefentry project='die-net'
><refentrytitle>pkg-config
</refentrytitle><manvolnum>1</manvolnum></citerefentry>
204 <title>See Also
</title>
207 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
208 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
209 <citerefentry><refentrytitle>sd_bus_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>