| 1 |
'\" t |
| 2 |
.TH "SD_BUS_ATTACH_EVENT" "3" "" "systemd 261~rc3" "sd_bus_attach_event" |
| 3 |
.\" ----------------------------------------------------------------- |
| 4 |
.\" * Define some portability stuff |
| 5 |
.\" ----------------------------------------------------------------- |
| 6 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 7 |
.\" http://bugs.debian.org/507673 |
| 8 |
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html |
| 9 |
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 10 |
.ie \n(.g .ds Aq \(aq |
| 11 |
.el .ds Aq ' |
| 12 |
.\" ----------------------------------------------------------------- |
| 13 |
.\" * set default formatting |
| 14 |
.\" ----------------------------------------------------------------- |
| 15 |
.\" disable hyphenation |
| 16 |
.nh |
| 17 |
.\" disable justification (adjust text to left margin only) |
| 18 |
.ad l |
| 19 |
.\" ----------------------------------------------------------------- |
| 20 |
.\" * MAIN CONTENT STARTS HERE * |
| 21 |
.\" ----------------------------------------------------------------- |
| 22 |
.SH "NAME" |
| 23 |
sd_bus_attach_event, sd_bus_detach_event, sd_bus_get_event \- Attach a bus connection object to an event loop |
| 24 |
.SH "SYNOPSIS" |
| 25 |
.sp |
| 26 |
.ft B |
| 27 |
.nf |
| 28 |
#include <systemd/sd\-bus\&.h> |
| 29 |
.fi |
| 30 |
.ft |
| 31 |
.HP \w'int\ sd_bus_attach_event('u |
| 32 |
.BI "int sd_bus_attach_event(sd_bus\ *" "bus" ", sd_event\ *" "e" ", int\ " "priority" ");" |
| 33 |
.HP \w'int\ sd_bus_detach_event('u |
| 34 |
.BI "int sd_bus_detach_event(sd_bus\ *" "bus" ");" |
| 35 |
.HP \w'sd_event\ *sd_bus_get_event('u |
| 36 |
.BI "sd_event *sd_bus_get_event(sd_bus\ *" "bus" ");" |
| 37 |
.SH "DESCRIPTION" |
| 38 |
.PP |
| 39 |
\fBsd_bus_attach_event()\fR |
| 40 |
attaches the specified bus connection object to an |
| 41 |
\fBsd-event\fR(3) |
| 42 |
event loop object at the specified priority (see |
| 43 |
\fBsd_event_source_set_priority\fR(3) |
| 44 |
for details on event loop priorities)\&. When a bus connection object is attached to an event loop incoming messages will be automatically read and processed, and outgoing messages written, whenever the event loop is run\&. When the event loop is about to terminate, the bus connection is automatically flushed and closed (see |
| 45 |
\fBsd_bus_set_close_on_exit\fR(3) |
| 46 |
for details on this)\&. By default, bus connection objects are not attached to any event loop\&. When a bus connection object is attached to one it is not necessary to invoke |
| 47 |
\fBsd_bus_wait\fR(3) |
| 48 |
or |
| 49 |
\fBsd_bus_process\fR(3) |
| 50 |
as this functionality is handled automatically by the event loop\&. |
| 51 |
.PP |
| 52 |
\fBsd_bus_detach_event()\fR |
| 53 |
detaches a bus object from its event loop\&. |
| 54 |
.PP |
| 55 |
The |
| 56 |
\fBsd_bus_get_event()\fR |
| 57 |
returns the event loop object the specified bus object is currently attached to, or |
| 58 |
\fBNULL\fR |
| 59 |
if it is currently not attached to any\&. |
| 60 |
.PP |
| 61 |
Note that |
| 62 |
\fBsd_bus_attach_event()\fR |
| 63 |
is only one of three supported ways to implement I/O event handling for bus connections\&. Alternatively use |
| 64 |
\fBsd_bus_get_fd\fR(3) |
| 65 |
for hooking up a bus connection object with external or manual event loops\&. Or use |
| 66 |
\fBsd_bus_wait\fR(3) |
| 67 |
as a simple synchronous, blocking I/O waiting call\&. |
| 68 |
.SH "RETURN VALUE" |
| 69 |
.PP |
| 70 |
On success, |
| 71 |
\fBsd_bus_attach_event()\fR |
| 72 |
and |
| 73 |
\fBsd_bus_detach_event()\fR |
| 74 |
return 0 or a positive integer\&. On failure, they return a negative errno\-style error code\&. |
| 75 |
.PP |
| 76 |
\fBsd_bus_get_event()\fR |
| 77 |
returns an event loop object or |
| 78 |
\fBNULL\fR\&. |
| 79 |
.SS "Errors" |
| 80 |
.PP |
| 81 |
Returned errors may indicate the following problems: |
| 82 |
.PP |
| 83 |
\fB\-ECHILD\fR |
| 84 |
.RS 4 |
| 85 |
The bus connection has been created in a different process, library or module instance\&. |
| 86 |
.RE |
| 87 |
.SH "NOTES" |
| 88 |
.PP |
| 89 |
Functions described here are available as a shared library, which can be compiled against and linked to with the |
| 90 |
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1) |
| 91 |
file\&. |
| 92 |
.PP |
| 93 |
The code described here uses |
| 94 |
\fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call |
| 95 |
\fBsetenv\fR(3) |
| 96 |
from a parallel thread\&. It is recommended to only do calls to |
| 97 |
\fBsetenv()\fR |
| 98 |
from an early phase of the program when no other threads have been started\&. |
| 99 |
.SH "HISTORY" |
| 100 |
.PP |
| 101 |
\fBsd_bus_attach_event()\fR, |
| 102 |
\fBsd_bus_detach_event()\fR, and |
| 103 |
\fBsd_bus_get_event()\fR |
| 104 |
were added in version 221\&. |
| 105 |
.SH "SEE ALSO" |
| 106 |
.PP |
| 107 |
\fBsystemd\fR(1), \fBsd-bus\fR(3), \fBsd-event\fR(3), \fBsd_event_source_set_priority\fR(3), \fBsd_bus_set_close_on_exit\fR(3), \fBsd_bus_wait\fR(3), \fBsd_bus_get_fd\fR(3) |