]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/sd_bus_attach_event.xml
Merge pull request #11827 from keszybz/pkgconfig-variables
[thirdparty/systemd.git] / man / sd_bus_attach_event.xml
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6 SPDX-License-Identifier: LGPL-2.1+
7 -->
8
9 <refentry id="sd_bus_attach_event"
10 xmlns:xi="http://www.w3.org/2001/XInclude">
11
12 <refentryinfo>
13 <title>sd_bus_attach_event</title>
14 <productname>systemd</productname>
15 </refentryinfo>
16
17 <refmeta>
18 <refentrytitle>sd_bus_attach_event</refentrytitle>
19 <manvolnum>3</manvolnum>
20 </refmeta>
21
22 <refnamediv>
23 <refname>sd_bus_attach_event</refname>
24 <refname>sd_bus_detach_event</refname>
25 <refname>sd_bus_get_event</refname>
26
27 <refpurpose>Attach a bus connection object to an event loop</refpurpose>
28 </refnamediv>
29
30 <refsynopsisdiv>
31 <funcsynopsis>
32 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
33
34 <funcprototype>
35 <funcdef>int <function>sd_bus_attach_event</function></funcdef>
36 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
37 <paramdef>sd_event *<parameter>e</parameter></paramdef>
38 <paramdef>int <parameter>priority</parameter></paramdef>
39 </funcprototype>
40
41 <funcprototype>
42 <funcdef>int <function>sd_bus_detach_event</function></funcdef>
43 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
44 </funcprototype>
45
46 <funcprototype>
47 <funcdef>sd_event *<function>sd_bus_get_event</function></funcdef>
48 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
49 </funcprototype>
50 </funcsynopsis>
51 </refsynopsisdiv>
52
53 <refsect1>
54 <title>Description</title>
55
56 <para><function>sd_bus_attach_event()</function> attaches the specified bus connection object to an
57 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry> event loop object at
58 the specified priority (see
59 <citerefentry><refentrytitle>sd_event_source_set_priority</refentrytitle><manvolnum>3</manvolnum></citerefentry>
60 for details on event loop priorities). When a bus connection object is attached to an event loop incoming messages
61 will be automatically read and processed, and outgoing messages written, whenever the event loop is run. When the
62 event loop is about to terminate, the bus connection is automatically flushed and closed (see
63 <citerefentry><refentrytitle>sd_bus_set_close_on_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry> for
64 details on this). By default bus connection objects are not attached to any event loop. When a bus connection
65 object is attached to one it is not necessary to invoke
66 <citerefentry><refentrytitle>sd_bus_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry> or
67 <citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry> as this
68 functionality is handled automatically by the event loop.</para>
69
70 <para><function>sd_bus_detach_event()</function> detaches a bus object from its event loop.</para>
71
72 <para>The <function>sd_bus_get_event()</function> returns the event loop object the specified bus object is
73 currently attached to, or <constant>NULL</constant> if it is currently not attached to any.</para>
74
75 <para>Note that <function>sd_bus_attach_event()</function> is only one of three supported ways to implement I/O
76 event handling for bus connections. Alternatively use
77 <citerefentry><refentrytitle>sd_bus_get_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry> for hooking up a
78 bus connection object with external or manual event loops. Or use
79 <citerefentry><refentrytitle>sd_bus_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry> as a simple
80 synchronous, blocking I/O waiting call.</para>
81 </refsect1>
82
83 <refsect1>
84 <title>Return Value</title>
85
86 <para>On success, <function>sd_bus_attach_event()</function> and <function>sd_bus_detach_event()</function> return
87 0 or a positive integer. On failure, they return a negative errno-style error code.</para>
88
89 <para><function>sd_bus_get_event()</function> returns an event loop object or <constant>NULL</constant>.</para>
90 </refsect1>
91
92 <refsect1>
93 <title>Errors</title>
94
95 <para>Returned errors may indicate the following problems:</para>
96
97 <variablelist>
98 <varlistentry>
99 <term><constant>-ECHILD</constant></term>
100
101 <listitem><para>The bus connection has been created in a different process.</para></listitem>
102 </varlistentry>
103 </variablelist>
104 </refsect1>
105
106 <xi:include href="libsystemd-pkgconfig.xml" />
107
108 <refsect1>
109 <title>See Also</title>
110
111 <para>
112 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
113 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
114 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
115 <citerefentry><refentrytitle>sd_event_source_set_priority</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
116 <citerefentry><refentrytitle>sd_bus_set_close_on_exit</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
117 <citerefentry><refentrytitle>sd_bus_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
118 <citerefentry><refentrytitle>sd_bus_get_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>
119 </para>
120 </refsect1>
121
122 </refentry>