SD_BUS_S...ISCONNECT(3)
π
SD_BUS_S...ISCONNECT(3) β sd_bus_set_exit_on_disconnect π
okay bestie, welcome to the manual page for sd_bus_set_exit_on_disconnect (the page header calls it SD_BUS_S...ISCONNECT(3)), and itβs all about controlling what happens when your bus object disconnects. no cap. β¨
πΈ NAME πΈ
sd_bus_set_exit_on_disconnect, sd_bus_get_exit_on_disconnect β control the exit behavior when the bus object disconnects. thatβs the whole plot, and honestly itβs giving βtiny switch, big consequences.β π
β¨ SYNOPSIS β¨
#include <systemd/sd-bus.h>
int sd_bus_set_exit_on_disconnect(sd_bus *bus, int b);
int sd_bus_get_exit_on_disconnect(sd_bus *bus);
π¦ DESCRIPTION π¦
so sd_bus_set_exit_on_disconnect() may be used to configure the exit behavior when the given bus object disconnects. yes bestie, itβs literally the βwhat do we do when this thing bails?β button. π
if b is zero, no special logic is executed when the bus object disconnects. itβs justβ¦ nothing. calm. no drama. π
if b is non-zero, the behavior on disconnect depends on whether the bus object is attached to an event loop or not. this is the part where you gotta know your setup, fr fr. β¨
- if the bus object is attached to an event loop (see
sd_bus_attach_event(3)), the event loop is closed when the bus object disconnects β as if callingsd_event_exit(3). π - otherwise,
exit(3)is called. π
the exit code passed to sd_event_exit() and exit() is EXIT_FAILURE. periodt. π₯
bestie, if the bus object has already disconnected when enabling the exit behavior, the exit behavior is executed immediately β not later, not after a vibe check. π
by default, the exit behavior is disabled. so if you want this energy, you gotta turn it on yourself. π
sd_bus_get_exit_on_disconnect() returns whether the exit on disconnect behavior is enabled for the given bus object. itβs the little βis this thing on?β check. π«Ά
π RETURN VALUE π
- on success,
sd_bus_set_exit_on_disconnect()returns a non-negative integer. slay. β¨ - on failure, it returns a negative errno-style error code. not slay, but useful. π
sd_bus_get_exit_on_disconnect() returns a positive integer if the exit on disconnect behavior is enabled. otherwise, it returns zero. simple as that. π
π Errors π
returned errors may indicate the following problems:
-EINVALβ a required parameter wasNULL. Added in version 246. bestie, someone forgot to pass the thing. π-ENOPKGβ the bus object could not be resolved. Added in version 246. itβs giving βcanβt find the main character.β π-ECHILDβ the bus connection was created in a different process, library or module instance. Added in version 246. wrong family, wrong house. π«
π 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 build-system behavior, honestly. β¨
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 responsibly, bestie. π«Ά
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. π₯ no chaotic parallelsetenv(3)energy. keep it early, keep it cute. π
π HISTORY π
sd_bus_set_exit_on_disconnect() and sd_bus_get_exit_on_disconnect() were added in version 246. a little vintage, a little iconic. π
β SEE ALSO β
π cute sign-off: this page is from systemd 261.3 β and the original footerβs date slot is not filled in on this copy, so no date to report, bestie. π
π¦ 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