From cd6d2111c496ace8370974394c766178ae0c8f40 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 20 Feb 2021 14:03:34 +0100 Subject: man: split out sd_bus_set_fd() man page from sd_bus_get_fd() sd_bus_get_fd() and related calls are useful for integrating a bus connection into arbitrary event loops. But sd_bus_set_fd() is quite a different beast, it's for using D-Bus over pre-initialized sockets or pairs of fifos or stuff, i.e. very advanced stuff. Let's split this man page in two, in order not to confuse things needlessly. And while we are at it, let's slightly extend the documentation. --- man/rules/meson.build | 6 +-- man/sd_bus_get_fd.xml | 24 +--------- man/sd_bus_set_fd.xml | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+), 27 deletions(-) create mode 100644 man/sd_bus_set_fd.xml (limited to 'man') diff --git a/man/rules/meson.build b/man/rules/meson.build index 763863afef..a48158f562 100644 --- a/man/rules/meson.build +++ b/man/rules/meson.build @@ -269,10 +269,7 @@ manpages = [ 'sd_bus_get_current_slot', 'sd_bus_get_current_userdata'], ''], - ['sd_bus_get_fd', - '3', - ['sd_bus_get_events', 'sd_bus_get_timeout', 'sd_bus_set_fd'], - ''], + ['sd_bus_get_fd', '3', ['sd_bus_get_events', 'sd_bus_get_timeout'], ''], ['sd_bus_get_n_queued_read', '3', ['sd_bus_get_n_queued_write'], ''], ['sd_bus_get_name_creds', '3', ['sd_bus_get_owner_creds'], ''], ['sd_bus_get_name_machine_id', '3', [], ''], @@ -430,6 +427,7 @@ manpages = [ 'sd_bus_set_trusted'], ''], ['sd_bus_set_exit_on_disconnect', '3', ['sd_bus_get_exit_on_disconnect'], ''], + ['sd_bus_set_fd', '3', [], ''], ['sd_bus_set_method_call_timeout', '3', ['sd_bus_get_method_call_timeout'], diff --git a/man/sd_bus_get_fd.xml b/man/sd_bus_get_fd.xml index 7297db316f..2c0ec8fc05 100644 --- a/man/sd_bus_get_fd.xml +++ b/man/sd_bus_get_fd.xml @@ -22,7 +22,6 @@ sd_bus_get_fd - sd_bus_set_fd sd_bus_get_events sd_bus_get_timeout @@ -39,13 +38,6 @@ sd_bus *bus - - int sd_bus_set_fd - sd_bus *bus - int input_fd - int output_fd - - int sd_bus_get_events sd_bus *bus @@ -69,11 +61,6 @@ object was configured with the sd_bus_set_fd() function, then the input_fd file descriptor used in that call is returned. - sd_bus_set_fd() sets the file descriptors used to communicate from a - message bus object. Both input_fd and output_fd - must be valid file descriptors. The same file descriptor may be used as both the input and the - output file descriptor. This function must be called before the bus is started. - sd_bus_get_events() returns the I/O events to wait for, suitable for passing to poll() or a similar call. Returns a combination of POLLIN, POLLOUT, … events, or negative on error. @@ -122,9 +109,6 @@ On success, sd_bus_get_fd() returns the file descriptor used for communication. On failure, it returns a negative errno-style error code. - On success, sd_bus_set_fd() returns a non-negative integer. On - failure, it returns a negative errno-style error code. - On success, sd_bus_get_events() returns the I/O event mask to use for I/O event watching. On failure, it returns a negative errno-style error code. @@ -164,13 +148,6 @@ return. - - -EBADF - - An invalid file descriptor was passed to - sd_bus_set_fd(). - - -ENOPKG @@ -191,6 +168,7 @@ sd_bus_process3, sd_bus_attach_event3, sd_bus_wait3, + sd_bus_set_fd3, poll3 diff --git a/man/sd_bus_set_fd.xml b/man/sd_bus_set_fd.xml new file mode 100644 index 0000000000..3860ab06cd --- /dev/null +++ b/man/sd_bus_set_fd.xml @@ -0,0 +1,120 @@ + + + + + + + + + sd_bus_set_fd + systemd + + + + sd_bus_set_fd + 3 + + + + sd_bus_set_fd + + Set the file descriptors to use for bus communication + + + + + #include <systemd/sd-bus.h> + + + int sd_bus_set_fd + sd_bus *bus + int input_fd + int output_fd + + + + + + Description + + sd_bus_set_fd() sets the file descriptors used to communicate by a bus + connection object. Both input_fd and output_fd must be + valid file descriptors, referring to stream-based file objects (e.g. a stream socket, a pair of pipes or + FIFOs, or a even a TTY device). input_fd must be readable, and + output_fd must be writable. The same file descriptor may be used (and typically is + used) as both the input and the output file descriptor. This function must be called before the bus + connection is started via + sd_bus_start3. + + The bus connection object will take possession of the passed file descriptors and will close them + automatically when it is freed. Use + sd_bus_set_close_on_exit3 + to turn off this behaviour. + + + + Return Value + + On success, sd_bus_set_fd() returns a non-negative integer. On + failure, it returns a negative errno-style error code. + + + Errors + + Returned errors may indicate the following problems: + + + + -EINVAL + + An invalid bus object was passed. + + + + -ECHILD + + The bus connection was allocated in a parent process and is being reused + in a child process after fork(). + + + + -EBADF + + An invalid file descriptor was passed to + sd_bus_set_fd(). + + + + -ENOPKG + + The bus cannot be resolved. + + + + -EPERM + + The bus connection has aleady been started. + + + + + + + + + See Also + + + systemd1, + sd-bus3, + sd_bus_get_fd3, + sd_bus_start3 + + + + -- cgit v1.2.1