From: Daan De Meyer Date: Mon, 20 Apr 2020 18:59:27 +0000 (+0200) Subject: sd-bus: Rewrap sd_bus_get_fd docs X-Git-Tag: v246-rc1~553^2~3 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsystemd.git;a=commitdiff_plain;h=d4169bf8b06502759d7d41d256f41d6b67ac4788 sd-bus: Rewrap sd_bus_get_fd docs --- diff --git a/man/sd_bus_get_fd.xml b/man/sd_bus_get_fd.xml index 213d1390199..eb488b1e6f5 100644 --- a/man/sd_bus_get_fd.xml +++ b/man/sd_bus_get_fd.xml @@ -26,7 +26,8 @@ sd_bus_get_events sd_bus_get_timeout - Get the file descriptor, I/O events and time-out to wait for from a message bus object + Get the file descriptor, I/O events and time-out to wait for from a message bus + object @@ -61,65 +62,74 @@ Description - sd_bus_get_fd() returns the file descriptor used to communicate from a message bus - object. This descriptor can be used with poll3 or a similar - function to wait for I/O events on the specified bus connection object. If the bus 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. + sd_bus_get_fd() returns the file descriptor used to communicate from + a message bus object. This descriptor can be used with + poll3 + or a similar function to wait for I/O events on the specified bus connection object. If the bus + 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. + sd_bus_get_timeout() returns the time-out in µs to pass to to - poll() or a similar call when waiting for events on the specified bus connection. The returned - time-out may be zero, in which case a subsequent I/O polling call should be invoked in non-blocking mode. The - returned timeout may be UINT64_MAX in which case the I/O polling call may block indefinitely, - without any applied time-out. Note that the returned time-out should be considered only a maximum sleeping time. It - is permissible (and even expected) that shorter time-outs are used by the calling program, in case other event - sources are polled in the same event loop. Note that the returned time-value is relative and specified in - microseconds. When converting this value in order to pass it as third argument to poll() - (which expects milliseconds), care should be taken to use a division that rounds up to ensure the I/O polling - operation doesn't sleep for shorter than necessary, which might result in unintended busy looping (alternatively, - use ppoll3 - instead of plain poll(), which understands time-outs with nano-second granularity). - - These three functions are useful to hook up a bus connection object with an external or manual event loop - involving poll() or a similar I/O polling call. Before each invocation of the I/O polling - call, all three functions should be invoked: the file descriptor returned by sd_bus_get_fd() - should be polled for the events indicated by sd_bus_get_events(), and the I/O call should - block for that up to the time-out returned by sd_bus_get_timeout(). After each I/O polling + poll() or a similar call when waiting for events on the specified bus + connection. The returned time-out may be zero, in which case a subsequent I/O polling call + should be invoked in non-blocking mode. The returned timeout may be + UINT64_MAX in which case the I/O polling call may block indefinitely, + without any applied time-out. Note that the returned time-out should be considered only a + maximum sleeping time. It is permissible (and even expected) that shorter time-outs are used by + the calling program, in case other event sources are polled in the same event loop. Note that + the returned time-value is relative and specified in microseconds. When converting this value in + order to pass it as third argument to poll() (which expects milliseconds), + care should be taken to use a division that rounds up to ensure the I/O polling operation + doesn't sleep for shorter than necessary, which might result in unintended busy looping + (alternatively, use + ppoll3 + instead of plain poll(), which understands time-outs with nano-second + granularity). + + These three functions are useful to hook up a bus connection object with an external or + manual event loop involving poll() or a similar I/O polling call. Before + each invocation of the I/O polling call, all three functions should be invoked: the file + descriptor returned by sd_bus_get_fd() should be polled for the events + indicated by sd_bus_get_events(), and the I/O call should block for that up + to the time-out returned by sd_bus_get_timeout(). After each I/O polling call the bus connection needs to process incoming or outgoing data, by invoking - sd_bus_process3. + sd_bus_process3. + - Note that these function are only one of three supported ways to implement I/O event handling for bus - connections. Alternatively use - sd_bus_attach_event3 to attach a - bus connection to an sd-event3 - event loop. Or use sd_bus_wait3 + Note that these function are only one of three supported ways to implement I/O event + handling for bus connections. Alternatively use + sd_bus_attach_event3 + to attach a bus connection to an + sd-event3 + event loop. Or use + sd_bus_wait3 as a simple synchronous, blocking I/O waiting call. Return Value - 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_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_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. + 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. - On success, sd_bus_get_timeout() returns a non-negative integer. On failure, it returns a - negative errno-style error code. + On success, sd_bus_get_timeout() returns a non-negative integer. On + failure, it returns a negative errno-style error code. Errors @@ -136,8 +146,8 @@ -ECHILD - The bus connection was allocated in a parent process and is being reused in a child - process after fork(). + The bus connection was allocated in a parent process and is being reused + in a child process after fork(). @@ -157,8 +167,8 @@ -EBADF - An invalid file descriptor was passed to sd_bus_set_fd(). - + An invalid file descriptor was passed to + sd_bus_set_fd().