SD-BUS(3)

🌈 SD-BUS(3) β€” the sd-bus page, bestie edition 🌈

okay so real quick, the manual name is sd-bus and this is section 3, which is the "library functions" section β€” iykyk. Let's get into it πŸ’…


✨ NAME ✨

sd-bus β€” a lightweight D-Bus IPC client library πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

#include <systemd/sd-bus.h>

pkg-config --cflags --libs libsystemd

that's it. that's the whole vibe check. 🫢


πŸ’– DESCRIPTION πŸ’–

sd-bus.h is part of libsystemd(3), and what it gives you is a whole implementation of a D-Bus IPC client. If you're like "girl what is D-Bus IPC," there's a whole site for it: see https://www.freedesktop.org/software/dbus/ for more information about D-Bus IPC. ✨

and like… there are so many functions. genuinely obsessed with how many. here's the full guest list, no plus-ones cut, promise πŸ‘‘:

sd_bus_add_match(3),
sd_bus_add_object(3),
sd_bus_add_object_manager(3),
sd_bus_add_object_vtable(3),
sd_bus_add_fallback(3),
sd_bus_add_fallback_vtable(3),
sd_bus_add_filter(3),
sd_bus_add_node_enumerator(3),
sd_bus_attach_event(3),
sd_bus_call(3),
sd_bus_call_async(3),
sd_bus_call_method(3),
sd_bus_call_method_async(3),
sd_bus_can_send(3),
sd_bus_close(3),
sd_bus_creds_get_pid(3),
sd_bus_creds_new_from_pid(3),
sd_bus_default(3),
sd_bus_emit_interfaces_added(3),
sd_bus_emit_interfaces_added_strv(3),
sd_bus_emit_interfaces_removed(3),
sd_bus_emit_interfaces_removed_strv(3),
sd_bus_emit_object_added(3),
sd_bus_emit_object_removed(3),
sd_bus_emit_properties_changed(3),
sd_bus_emit_properties_changed_strv(3),
sd_bus_emit_signal(3),
sd_bus_emit_signalv(3),
sd_bus_emit_signal_to(3),
sd_bus_emit_signal_tov(3),
sd_bus_enqueue_for_read(3),
sd-bus-errors(3),
sd_bus_error(3),
sd_bus_error_add_map(3),
sd_bus_get_address(3),
sd_bus_get_allow_interactive_authorization(3),
sd_bus_get_bus_id(3),
sd_bus_get_creds_mask(3),
sd_bus_get_current_handler(3),
sd_bus_get_current_message(3),
sd_bus_get_current_slot(3),
sd_bus_get_current_userdata(3),
sd_bus_get_exit_on_disconnect(3),
sd_bus_get_fd(3),
sd_bus_get_method_call_timeout(3),
sd_bus_get_n_queued_read(3),
sd_bus_get_name_creds(3),
sd_bus_get_name_machine_id(3),
sd_bus_get_owner_creds(3),
sd_bus_get_property(3),
sd_bus_get_property_string(3),
sd_bus_get_property_strv(3),
sd_bus_get_property_trivial(3),
sd_bus_get_scope(3),
sd_bus_get_tid(3),
sd_bus_get_unique_name(3),
sd_bus_interface_name_is_valid(3),
sd_bus_is_bus_client(3),
sd_bus_is_monitor(3),
sd_bus_is_open(3),
sd_bus_is_server(3),
sd_bus_list_names(3),
sd_bus_message_append(3),
sd_bus_message_append_array(3),
sd_bus_message_append_basic(3),
sd_bus_message_append_string_memfd(3),
sd_bus_message_append_strv(3),
sd_bus_message_at_end(3),
sd_bus_message_close_container(3),
sd_bus_message_copy(3),
sd_bus_message_dump(3),
sd_bus_message_enter_container(3),
sd_bus_message_exit_container(3),
sd_bus_message_get_allow_interactive_authorization(3),
sd_bus_message_get_cookie(3),
sd_bus_message_get_creds(3),
sd_bus_message_get_errno(3),
sd_bus_message_get_error(3),
sd_bus_message_get_monotonic_usec(3),
sd_bus_message_get_sender(3),
sd_bus_message_get_signature(3),
sd_bus_message_get_type(3),
sd_bus_message_new(3),
sd_bus_message_new_method_call(3),
sd_bus_message_new_method_error(3),
sd_bus_message_new_signal(3),
sd_bus_message_new_signal_to(3),
sd_bus_message_open_container(3),
sd_bus_message_peek_type(3),
sd_bus_message_read(3),
sd_bus_message_read_array(3),
sd_bus_message_read_basic(3),
sd_bus_message_read_strv(3),
sd_bus_message_rewind(3),
sd_bus_message_seal(3),
sd_bus_message_send(3),
sd_bus_message_sensitive(3),
sd_bus_message_set_allow_interactive_authorization(3),
sd_bus_message_set_destination(3),
sd_bus_message_set_expect_reply(3),
sd_bus_message_set_sender(3),
sd_bus_message_skip(3),
sd_bus_message_verify_type(3),
sd_bus_negotiate_fds(3),
sd_bus_new(3),
sd_bus_path_encode(3),
sd_bus_pending_method_calls(3),
sd_bus_process(3),
sd_bus_query_sender_creds(3),
sd_bus_query_sender_privilege(3),
sd_bus_reply_method_error(3),
sd_bus_reply_method_return(3),
sd_bus_request_name(3),
sd_bus_send(3),
sd_bus_send_to(3),
sd_bus_set_address(3),
sd_bus_set_allow_interactive_authorization(3),
sd_bus_set_bus_client(3),
sd_bus_set_close_on_exit(3),
sd_bus_set_connected_signal(3),
sd_bus_set_description(3),
sd_bus_set_exit_on_disconnect(3),
sd_bus_set_fd(3),
sd_bus_set_method_call_timeout(3),
sd_bus_set_monitor(3),
sd_bus_set_property(3),
sd_bus_set_propertyv(3),
sd_bus_set_sender(3),
sd_bus_set_server(3),
sd_bus_set_watch_bind(3)
sd_bus_slot_get_current_handler(3),
sd_bus_slot_get_current_message(3),
sd_bus_slot_get_current_userdata(3),
sd_bus_slot_set_description(3),
sd_bus_slot_set_destroy_callback(3),
sd_bus_slot_set_floating(3),
sd_bus_slot_set_userdata(3),
sd_bus_start(3),
sd_bus_track_add_name(3),
sd_bus_track_new(3),
sd_bus_wait(3)

…for more information about the functions available. yes, all of them. every single one. 🫑

and the busctl(1) tool makes the functionality implemented by sd-bus available from the command line β€” so if you're not about that C life, that's your girl πŸ’–


πŸ¦‹ 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. slay, standard, love that for us ⭐

okay now the important one, bestie, pay attention 🚨:

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. πŸ’€

so like… do your setenv() early, before the threads wake up, and nobody gets hurt. periodt.


🌸 SEE ALSO 🌸

systemd(1), sd-event(3), busctl(1), sd-varlink(3), dbus-daemon(1), dbus-send(1), pkg-config(1)


mwah πŸ’œ that's the whole page. written by the systemd girlies β€” this is the systemd 261.3 era, and the page itself is SD-BUS(3), so go forth and bus your sd's, icon. 🧚✨

πŸ“¦ where this page comes from