SD_BUS_ENQUEUE_FOR_READ(3)
π SD_BUS_ENQUEUE_FOR_READ(3) β like, the manual page bestie π
okay so this is the page for sd_bus_enqueue_for_read, out of the sd_bus_enqueue_for_read section of the systemd manuals (yes the header's a whole thing, we're not doing that, we're doing vibes). sit down, grab a matcha, let's get into it π
β¨ NAME β¨
sd_bus_enqueue_for_read β the way you put a bus message back on a bus connection's queue so it can be read again. it's giving rewind, not restart π«
β¨ SYNOPSIS β¨
#include <systemd/sd-bus.h>
int sd_bus_enqueue_for_read(sd_bus *bus, sd_bus_message *message);
two args, no drama. she's simple like that π
β¨ DESCRIPTION β¨
so sd_bus_enqueue_for_read() is literally the "put it back, we're not done with it" function. it re-enqueues an incoming bus message onto the local read queue, so it gets processed and dispatched locally all over again β exactly like how a fresh incoming message from the peer gets handled. same energy, second time around π
it takes a bus connection object and the message you want to enqueue. a reference is taken of the message, which means the caller's own reference stays right where it belongs β with the caller. no stealing, we're polite π«Ά
and the message goes to the end of the queue bestie, so it gets dispatched after everything that was already queued. no cutting the line, no main character behavior in the queue π
now the important part, the actual use case: this call is primarily for incoming method calls that can only be processed after some other asynchronous operation finishes. the iconic example is PolicyKit authorization β when a newly incoming method call needs authorization, and then the PolicyKit response finally comes back, you can re-enqueue that original method call and process it again, this time with the authorization result known. chef's kiss, ate, no notes π
β¨ RETURN VALUE β¨
- on success: she returns
0or a positive integer π - on failure: negative errno-style error code, as is tradition π
Errors
the errors she might throw your way:
-ECHILDβ the bus connection was created in a different process, library or module instance. different universe, can't touch this π
β¨ NOTES β¨
the functions described here are available as a shared library, which you can compile against and link to with the libsystemd pkg-config(1) file. link her up π
all functions listed here are thread-agnostic, and only a single thread may operate on a given object at any given time. different threads can access the same object at different times. multiple independent objects? those can absolutely be used from different threads in parallel. sharing is fine, just not at the same time, iykyk πΈ
β οΈ the code described here usesgetenv(3), which is declared to be not multi-thread-safe. so if you're calling the functions described here, do not callsetenv(3)from a parallel thread. the recommendation is to only dosetenv()calls from an early phase of the program β before any other threads have been started. like, get it done first, then start the party π
β¨ HISTORY β¨
sd_bus_enqueue_for_read() was added in version 245. a classic, an icon, we stan β
β¨ SEE ALSO β¨
and that's the whole page bestie, no cap π this one's from systemd 261.3, page SD_BUS_ENQUEUE_FOR_READ(3) β go forth and re-enqueue responsibly, love u, bye π¦ππ
π¦ where this page comes from
- ubuntu stonking: libsystemd-dev 261.3-0ubuntu3 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms