mirror of
https://github.com/systemd/systemd
synced 2024-07-21 18:24:38 +00:00
sd-bus: Rewrap sd_bus_get_fd docs
This commit is contained in:
parent
842a362c3a
commit
d4169bf8b0
|
@ -26,7 +26,8 @@
|
|||
<refname>sd_bus_get_events</refname>
|
||||
<refname>sd_bus_get_timeout</refname>
|
||||
|
||||
<refpurpose>Get the file descriptor, I/O events and time-out to wait for from a message bus object</refpurpose>
|
||||
<refpurpose>Get the file descriptor, I/O events and time-out to wait for from a message bus
|
||||
object</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsynopsisdiv>
|
||||
|
@ -61,65 +62,74 @@
|
|||
<refsect1>
|
||||
<title>Description</title>
|
||||
|
||||
<para><function>sd_bus_get_fd()</function> returns the file descriptor used to communicate from a message bus
|
||||
object. This descriptor can be used with <citerefentry
|
||||
project='man-pages'><refentrytitle>poll</refentrytitle><manvolnum>3</manvolnum></citerefentry> or a similar
|
||||
function to wait for I/O events on the specified bus connection object. If the bus object was configured with the
|
||||
<function>sd_bus_set_fd()</function> function, then the <parameter>input_fd</parameter> file descriptor used in
|
||||
that call is returned.</para>
|
||||
<para><function>sd_bus_get_fd()</function> returns the file descriptor used to communicate from
|
||||
a message bus object. This descriptor can be used with
|
||||
<citerefentry project='man-pages'><refentrytitle>poll</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
or a similar function to wait for I/O events on the specified bus connection object. If the bus
|
||||
object was configured with the <function>sd_bus_set_fd()</function> function, then the
|
||||
<parameter>input_fd</parameter> file descriptor used in that call is returned.</para>
|
||||
|
||||
<para><function>sd_bus_set_fd()</function> sets the file descriptors used to communicate from a message bus
|
||||
object. Both <parameter>input_fd</parameter> and <parameter>output_fd</parameter> 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.</para>
|
||||
<para><function>sd_bus_set_fd()</function> sets the file descriptors used to communicate from a
|
||||
message bus object. Both <parameter>input_fd</parameter> and <parameter>output_fd</parameter>
|
||||
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.</para>
|
||||
|
||||
<para><function>sd_bus_get_events()</function> returns the I/O events to wait for, suitable for passing to
|
||||
<function>poll()</function> or a similar call. Returns a combination of <constant>POLLIN</constant>,
|
||||
<constant>POLLOUT</constant>, … events, or negative on error.</para>
|
||||
<para><function>sd_bus_get_events()</function> returns the I/O events to wait for, suitable for
|
||||
passing to <function>poll()</function> or a similar call. Returns a combination of
|
||||
<constant>POLLIN</constant>, <constant>POLLOUT</constant>, … events, or negative on error.
|
||||
</para>
|
||||
|
||||
<para><function>sd_bus_get_timeout()</function> returns the time-out in µs to pass to to
|
||||
<function>poll()</function> 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 <constant>UINT64_MAX</constant> 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 <function>poll()</function>
|
||||
(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 <citerefentry project='man-pages'><refentrytitle>ppoll</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
instead of plain <function>poll()</function>, which understands time-outs with nano-second granularity).</para>
|
||||
<function>poll()</function> 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
|
||||
<constant>UINT64_MAX</constant> 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 <function>poll()</function> (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
|
||||
<citerefentry project='man-pages'><refentrytitle>ppoll</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
instead of plain <function>poll()</function>, which understands time-outs with nano-second
|
||||
granularity).</para>
|
||||
|
||||
<para>These three functions are useful to hook up a bus connection object with an external or manual event loop
|
||||
involving <function>poll()</function> 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 <function>sd_bus_get_fd()</function>
|
||||
should be polled for the events indicated by <function>sd_bus_get_events()</function>, and the I/O call should
|
||||
block for that up to the time-out returned by <function>sd_bus_get_timeout()</function>. After each I/O polling
|
||||
<para>These three functions are useful to hook up a bus connection object with an external or
|
||||
manual event loop involving <function>poll()</function> 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 <function>sd_bus_get_fd()</function> should be polled for the events
|
||||
indicated by <function>sd_bus_get_events()</function>, and the I/O call should block for that up
|
||||
to the time-out returned by <function>sd_bus_get_timeout()</function>. After each I/O polling
|
||||
call the bus connection needs to process incoming or outgoing data, by invoking
|
||||
<citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
|
||||
<citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
|
||||
</para>
|
||||
|
||||
<para>Note that these function are only one of three supported ways to implement I/O event handling for bus
|
||||
connections. Alternatively use
|
||||
<citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry> to attach a
|
||||
bus connection to an <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
event loop. Or use <citerefentry><refentrytitle>sd_bus_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
<para>Note that these function are only one of three supported ways to implement I/O event
|
||||
handling for bus connections. Alternatively use
|
||||
<citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
to attach a bus connection to an
|
||||
<citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
event loop. Or use
|
||||
<citerefentry><refentrytitle>sd_bus_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
as a simple synchronous, blocking I/O waiting call.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>Return Value</title>
|
||||
|
||||
<para>On success, <function>sd_bus_get_fd()</function> returns the file descriptor used for communication. On failure,
|
||||
it returns a negative errno-style error code.</para>
|
||||
<para>On success, <function>sd_bus_get_fd()</function> returns the file descriptor used for
|
||||
communication. On failure, it returns a negative errno-style error code.</para>
|
||||
|
||||
<para>On success, <function>sd_bus_set_fd()</function> returns a non-negative integer. On failure, it returns a
|
||||
negative errno-style error code.</para>
|
||||
<para>On success, <function>sd_bus_set_fd()</function> returns a non-negative integer. On
|
||||
failure, it returns a negative errno-style error code.</para>
|
||||
|
||||
<para>On success, <function>sd_bus_get_events()</function> returns the I/O event mask to use for I/O event watching.
|
||||
On failure, it returns a negative errno-style error code.</para>
|
||||
<para>On success, <function>sd_bus_get_events()</function> returns the I/O event mask to use for
|
||||
I/O event watching. On failure, it returns a negative errno-style error code.</para>
|
||||
|
||||
<para>On success, <function>sd_bus_get_timeout()</function> returns a non-negative integer. On failure, it returns a
|
||||
negative errno-style error code.</para>
|
||||
<para>On success, <function>sd_bus_get_timeout()</function> returns a non-negative integer. On
|
||||
failure, it returns a negative errno-style error code.</para>
|
||||
|
||||
<refsect2>
|
||||
<title>Errors</title>
|
||||
|
@ -136,8 +146,8 @@
|
|||
<varlistentry>
|
||||
<term><constant>-ECHILD</constant></term>
|
||||
|
||||
<listitem><para>The bus connection was allocated in a parent process and is being reused in a child
|
||||
process after <function>fork()</function>.</para></listitem>
|
||||
<listitem><para>The bus connection was allocated in a parent process and is being reused
|
||||
in a child process after <function>fork()</function>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
@ -157,8 +167,8 @@
|
|||
<varlistentry>
|
||||
<term><constant>-EBADF</constant></term>
|
||||
|
||||
<listitem><para>An invalid file descriptor was passed to <function>sd_bus_set_fd()</function>.
|
||||
</para></listitem>
|
||||
<listitem><para>An invalid file descriptor was passed to
|
||||
<function>sd_bus_set_fd()</function>.</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
|
|
Loading…
Reference in a new issue