SD_EVENT_..._GET_EVENT(3)
π
SD_EVENT_..._GET_EVENT(3) β the sd_event_source_get_event page, bestie edition
ok so real quick, before we get into it: this whole page lives inside sd_event_source_get_event world, and the manual is literally called SD_EVENT_..._GET_EVENT(3). that's the vibe. let's go π«Ά
β¨ NAME β¨
sd_event_source_get_event β bestie, this is the one that gets you the event loop that your event source is attached to π
β¨ SYNOPSIS β¨
#include <systemd/sd-event.h>
sd_event* sd_event_source_get_event(sd_event_source *source);
that's it. that's the whole function. icon behavior tbh π
β¨ DESCRIPTION β¨
okay so sd_event_source_get_event() is what you call when you have an event source and you're like "wait. which event loop are you even hanging out with?" π
you pass in that event source as source, and it hands you back the event loop object that source is associated with. simple. elegant. slay β¨
and where did that event loop come from? not from nowhere, bes β the event loop object gets specified back when the event source object was created, via calls like sd_event_add_io(3) or sd_event_add_time(3). so it's giving "you already met your own event loop, you just forgot" ππ
β¨ RETURN VALUE β¨
- on success β
sd_event_source_get_event()returns the associated event loop object π - on failure β it returns
NULLπ
that's the whole deal. NULL means something went sideways, periodt.
β¨ NOTES β¨
okay the notes section, everybody sit down, this is the important lore π§
- everything described here is available as a shared library β you can compile against it and link to it with the
libsystemdpkg-config(1)file. yes, that's the pkg-config. go off π₯ - all the functions listed here are thread-agnostic β but heads up, only a single thread may operate on a given object at any given time. different threads can access the same object at different times though, no cap. and multiple independent objects? those can be used from different threads in parallel, all day, go off π
- π¨ okay this one matters: the code described here uses
getenv(3), which is declared to be not multi-thread-safe. which means: if you're calling the functions described here, you must not callsetenv(3)from a parallel thread. nope. don't. π
the recommended move: only do calls to setenv() from an early phase of the program, back when no other threads have been started yet. like, before the party gets going. π
β¨ HISTORY β¨
sd_event_source_get_event() was added in version 229. so it's been iconic for a minute π
β¨ SEE ALSO β¨
go read these next, bestie, they're all part of the same friend group π¦
sd-event(3)sd_event_add_io(3)sd_event_add_time(3)sd_event_add_signal(3)sd_event_add_child(3)sd_event_add_inotify(3)sd_event_add_defer(3)sd_event_source_set_userdata(3)
πΈ mwah, that's the page. this one's from systemd 261.3 and it's called SD_EVENT_..._GET_EVENT(3) β now go get yourself an event loop, you deserve it π
π¦ 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