SD_EVENT_...ET_PENDING(3)
π NAME π
ok so like β sd_event_source_get_pending β it's the little function that tells you whether your event source is pending or not, bestie. That's literally it, that's the whole vibe check β¨
πΈ SYNOPSIS πΈ
#include <systemd/sd-event.h>
int sd_event_source_get_pending(sd_event_source *source);
π¦ DESCRIPTION π¦
okay so picture this: sd_event_source_get_pending() is your new fave little detective π β you hand it the event source object you passed as source, and it tells you whether that source has, like, seen events but hasn't been dispatched yet. Which means it's marked "pending" π
that's the word, that's the whole thing.
So when do things start pending? Ngl, event source objects are not pending when they're first born, like when you create them with calls such as sd_event_add_io(3), sd_event_add_time(3) β except:
- the ones you make with
sd_event_add_defer(3)? yeah those are immediately marked pending, no waiting around, main character energy π - and
sd_event_add_exit(3)? for that one the whole "pending" concept is literally not defined π like it's just not a thing there
For the full deets, go read the respective manual pages, iykyk.
Here's the cute part π β in each event loop iteration, one event source out of all the pending ones gets dispatched. Just one. And the order? That's defined by the event source priority, as set with sd_event_source_set_priority(3) β
And a lil bonus for I/O event sources (the ones from sd_event_add_io(3)): you can call sd_event_source_get_io_revents(3) to query the type of event that's pending in more detail. Obsessed with the extra detail honestly π«Ά
π₯ RETURN VALUE π₯
On success, sd_event_source_get_pending() returns an integer greater than zero when the event source is marked pending, and zero when it's not marked pending. On failure? negative errno-style error code, tragic π
π Errors
Returned errors may indicate the following problems:
-EINVALβ source is not a valid pointer to ansd_event_sourceobject. like, that's not a real pointer bestie π©-EDOMβ source refers to an event source object created withsd_event_add_exit(3). we talked about this, pending isn't defined there β-ENOMEMβ Not enough memory. ran out of vibes (and RAM) π-ESTALEβ The event loop is already terminated. it's over, it's done, it's giving ghost town π»-ECHILDβ The event loop has been created in a different process, library or module instance. not your child, can't touch it π
β NOTES β
The functions described here are available as a shared library, which you can compile against and link to with the libsystemd pkg-config(1) file. slay π₯
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. And multiple independent objects may be used from different threads in parallel. so like, share objects responsibly π
β οΈ heads up bestie β the code described here usesgetenv(3), which is declared to be not multi-thread-safe. That means the code calling the functions described here must not callsetenv(3)from a parallel thread. The recommendation is to only do calls tosetenv()from an early phase of the program when no other threads have been started. early-phase setenv or it's chaos, no cap π§
π HISTORY π
sd_event_source_get_pending() was added in version 229. a classic, an icon, a legend π
π SEE ALSO π
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_unref(3)
okay that's the whole page, go forth and check your pending states π
β¨ this lil masterpiece is from systemd 261.3, and yeah the page name is the very chaotic SD_EVENT_...ET_PENDING(3) β mwah, bye 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