SD_BUS_SET_SENDER(3)
π
SD_BUS_SET_SENDER(3) β like, the sd_bus_set_sender manual, bestie
okay so this whole page lives in section 3 of the manual, and the star of the show is sd_bus_set_sender (with sd_bus_get_sender riding shotgun). Let's get into it β¨
πΈ NAME πΈ
sd_bus_set_sender, sd_bus_get_sender β configure the default sender for outgoing messages π«Ά
π SYNOPSIS π
#include <systemd/sd-bus.h>
int sd_bus_set_sender(sd_bus *bus, const char* name);
int sd_bus_get_sender(sd_bus *bus, const char** name);
β¨ DESCRIPTION β¨
So sd_bus_set_sender() is the one that sets up your default sender service name for outgoing messages. Like, it configures the vibe of who's sending. π
The service name you pass in the name parameter gets stamped onto all outgoing messages that get sent on the connection and that don't already have a sender set β for example, ones that were set through sd_bus_message_set_sender(3).
β οΈ Heads up, bestie: this function is only supported on direct connections, i.e. not on connections to a bus broker. Because the broker is gonna fill in the sender service name automatically anyway, so likeβ¦ it's already handled. π
By default, no sender name is configured, and hence messages are sent without the sender field set. That's the default state, no cap.
If name is passed as NULL, the default sender service name gets cleared, returning to the default state (if a default sender service name was set before). If you pass it as non-NULL, the name you give has to be a valid unique or well-known service name. No fake ones. π«
And sd_bus_get_sender()? That's your girl for querying the current default service name for outgoing messages. Peek at the current setting, iconic. π
π₯ RETURN VALUE π₯
On success, these functions return 0 or a positive integer. On failure, they return a negative errno-style error code. That's it, that's the deal. π
π Errors π
Returned errors may indicate the following problems:
-ECHILDβ the bus connection has been created in a different process, library or module instance. so like, not your connection to touch, respectfully π-EPERMβ the specified bus connection object is not a direct connection but a brokered connection. wrong kind of connection, bestie. π
π NOTES π
The functions described here are available as a shared library, which can be compiled against and linked to with the libsystemd pkg-config(1) file. π
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. Basically: share nicely, don't all grab the same object at once. β
β οΈ The code described here usesgetenv(3), which is declared to be not multi-thread-safe. This means that the code calling the functions described here must not callsetenv(3)from a parallel thread. It is recommended to only do calls tosetenv()from an early phase of the program when no other threads have been started. like, do the env stuff before the party starts, fr fr π§
π HISTORY π
sd_bus_set_sender() and sd_bus_get_sender() were added in version 237. vintage but still slaying π
π¦ SEE ALSO π¦
systemd(1), sd-bus(3), sd_bus_message_set_sender(3)
that's the whole page, periodt π and just so you know, this came from the systemd 261.3 source β mwah, go read sd-bus(3) next, iykyk π
π¦ 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