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

NAME

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

SYNOPSIS

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

DESCRIPTION

16       sd_bus_close() disconnects the specified bus connection. When this call
17       is invoked and the specified bus object refers to an active connection
18       it is immediately terminated. No further messages may be sent or
19       received on it. Any messages queued in the bus object (both incoming
20       and outgoing) are released. If invoked on NULL bus object or when the
21       bus connection is already closed this function executes no operation.
22       This call does not free or unreference the bus object itself. Use
23       sd_bus_unref(3) for that.
24
25       sd_bus_flush() synchronously writes out all outgoing queued message on
26       a bus connection if there are any. This function call may block if the
27       peer is not processing bus messages quickly.
28
29       Before a program exits it is usually a good idea to flush any pending
30       messages with sd_bus_flush() and then close connections with
31       sd_bus_close() to ensure that no unwritten messages are lost, no
32       further messages may be queued and all incoming but unprocessed
33       messages are released. After both operations have been done, it is a
34       good idea to also drop any remaining references to the bus object so
35       that it may be freed. Since these three operations are frequently done
36       together a helper call sd_bus_flush_close_unref(3) is provided that
37       combines them into one.
38

RETURN VALUE

40       On success, sd_bus_flush() returns 0 or a positive integer. On failure,
41       it returns a negative errno-style error code.
42
43   Errors
44       Returned errors may indicate the following problems:
45
46       -ECHILD
47           The bus connection has been created in a different process.
48

NOTES

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

SEE ALSO

54       systemd(1), sd-bus(3), sd_bus_unref(3), sd_bus_set_close_on_exit(3)
55
56
57
58systemd 245                                                    SD_BUS_CLOSE(3)
Impressum