1SD_BUS_CLOSE(3)                  sd_bus_close                  SD_BUS_CLOSE(3)
2
3
4

NAME

6       sd_bus_close, sd_bus_flush, sd_bus_default_flush_close - Close and
7       flush a bus connection
8

SYNOPSIS

10       #include <systemd/sd-bus.h>
11
12       void sd_bus_close(sd_bus *bus);
13
14       int sd_bus_flush(sd_bus *bus);
15
16       void sd_bus_default_flush_close(void);
17

DESCRIPTION

19       sd_bus_close() disconnects the specified bus connection. When this call
20       is invoked and the specified bus object refers to an active connection
21       it is immediately terminated. No further messages may be sent or
22       received on it. Any messages queued in the bus object (both incoming
23       and outgoing) are released. If invoked on NULL bus object or when the
24       bus connection is already closed this function executes no operation.
25       This call does not free or unreference the bus object itself. Use
26       sd_bus_unref(3) for that.
27
28       sd_bus_flush() synchronously writes out all outgoing queued message on
29       a bus connection if there are any. This function call may block if the
30       peer is not processing bus messages quickly.
31
32       Before a program exits it is usually a good idea to flush any pending
33       messages with sd_bus_flush() and then close connections with
34       sd_bus_close() to ensure that no unwritten messages are lost, no
35       further messages may be queued and all incoming but unprocessed
36       messages are released. After both operations have been done, it is a
37       good idea to also drop any remaining references to the bus object so
38       that it may be freed. Since these three operations are frequently done
39       together a helper call sd_bus_flush_close_unref(3) is provided that
40       combines them into one.
41
42       sd_bus_default_flush_close() is similar to sd_bus_flush_close_unref(),
43       but does not take a bus pointer argument and instead iterates over any
44       of the "default" buses opened by sd_bus_default(3),
45       sd_bus_default_user(3), sd_bus_default_system(3), and similar calls.
46       sd_bus_default_flush_close() is particularly useful to clean up any
47       buses opened using those calls before the program exits.
48

RETURN VALUE

50       On success, sd_bus_flush() returns a non-negative integer. On failure,
51       it returns a negative errno-style error code.
52
53   Errors
54       Returned errors may indicate the following problems:
55
56       -ECHILD
57           The bus connection has been created in a different process.
58

NOTES

60       These APIs are implemented as a shared library, which can be compiled
61       and linked to with the libsystemd pkg-config(1) file.
62

SEE ALSO

64       systemd(1), sd-bus(3), sd_bus_unref(3), sd_bus_set_close_on_exit(3)
65
66
67
68systemd 251                                                    SD_BUS_CLOSE(3)
Impressum