SD_BUS_SE...TED_SIGNAL(3)

πŸ’– SD_BUS_SE...TED_SIGNAL(3) β€” the one where your bus connection finally says hi πŸ’–

Okay bestie, so this is from the sd_bus_set_connected_signal manual, and it's literally all about controlling whether your bus connection emits a cute little local "Connected()" signal when it's fully ready. No cap, it's giving "finally arrived" energy. πŸŽ€


✨ NAME ✨

sd_bus_set_connected_signal, sd_bus_get_connected_signal β€” control emission of the local connection establishment signal on bus connections. Yes, that's the whole vibe. πŸ’…


🌸 SYNOPSIS 🌸

#include <systemd/sd-bus.h>

int sd_bus_set_connected_signal(sd_bus *bus, int b);

int sd_bus_get_connected_signal(sd_bus *bus);

πŸ¦‹ DESCRIPTION πŸ¦‹

So sd_bus_set_connected_signal() is the main character here. It lets you control whether a local, synthetic Connected() signal message gets generated and enqueued for dispatching when the connection is fully established. If the b parameter is zero, the message is not generated (and yes, that's the default), otherwise it is generated. It's literally that simple. ✨

Then you've got sd_bus_get_connected_signal(), which is the nosy bestie β€” it queries whether this feature is enabled. It returns zero if not, positive otherwise. Slay. πŸ’…

The Connected() signal message is generated from the "org.freedesktop.DBus.Local" service and interface, and the "/org/freedesktop/DBus/Local" object path. Use sd_bus_match_signal_async(3) to match on this signal, iykyk. πŸ”₯

This message is particularly useful on slow transports where connections take a long time to be established β€” especially when sd_bus_set_watch_bind(3) is used. The signal is generated when sd_bus_is_ready(3) returns positive for the first time. Periodt. ⭐

And here's the tea: the Connected() signal corresponds with the Disconnected() signal that is synthesized locally when the connection is terminated. But the latter is generated unconditionally, unlike the former, which needs to be enabled explicitly before it is generated, with sd_bus_set_connected_signal(). Not me explaining the whole family tree, but here we are. 😭


πŸ’œ RETURN VALUE πŸ’œ

On success, these functions return 0 or a positive integer. On failure, they return a negative errno-style error code. That's the standard slay. 🫢

πŸ“ Errors πŸ“

Returned errors may indicate the following problems:

  • -ECHILD β€” the bus connection has been created in a different process, library or module instance. Rude, but okay. πŸ’€

🌈 NOTES 🌈

Functions described here are available as a shared library, which can be compiled against and linked to with the libsystemd pkg-config(1) file. Iconic. πŸ‘‘

All functions listed here are thread-agnostic and only a single thread may operate on a given object at any given time. Different threads may access the same object at different times. Multiple independent objects may be used from different threads in parallel. So like, share the object, don't fight over it. 🧚

The code described here uses getenv(3), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not call setenv(3) from a parallel thread. It is recommended to only do calls to setenv() from an early phase of the program when no other threads have been started. Fr fr, don't test it. πŸ™ˆ

πŸŽ€ HISTORY πŸŽ€

sd_bus_set_connected_signal() and sd_bus_get_connected_signal() were added in version 237. Vintage but still cute. πŸ’–


⭐ SEE ALSO ⭐

systemd(1), sd-bus(3), sd_bus_match_signal_async(3), sd_bus_set_watch_bind(3), sd_bus_is_ready(3)


That's the whole page, bestie. This little gem comes from systemd 261.3 (yes, the manpage footer said so), and it's all yours. Now go enable that Connected() signal and live your best bus life. πŸŒΈπŸ’œπŸ¦‹

πŸ“¦ where this page comes from