SD_BOOTED(3)

πŸ’… SD_BOOTED(3) β€” the sd_booted era πŸ’…

okay so bestie, welcome to sd_booted, a little function from the sd-daemon family that answers one very important question: is this box even running systemd?? ✨


🌸 SYNOPSIS 🌸

#include <systemd/sd-daemon.h>

int sd_booted(void);

literally just include the header and call it with no args. that's it. slay. πŸŽ€


πŸ¦‹ DESCRIPTION πŸ¦‹

sd_booted() checks whether the system was booted up using the systemd init system. that's the whole vibe check, no cap. 🫢


⭐ RETURN VALUE ⭐

okay so the return values matter, don't skip this part:

  • On failure, this call returns a negative errno-style error code 😭
  • If the system was booted up with systemd as init system, this call returns a positive return value πŸ‘‘
  • Otherwise, it returns zero πŸ’€

so like: positive = yes systemd, zero = no systemd, negative = something went sideways. three whole moods fr fr.


🧚 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. iconic build-system behaviour, we love to see it. πŸ’–

internally, this function checks whether the directory /run/systemd/system/ exists. that's the entire secret sauce πŸ‘€ β€” a simple check like this can also be implemented trivially in shell or any other language. so if you were expecting dark magic, sorry bestie, it's just a directory existence check. πŸ™ˆ


🌈 SEE ALSO 🌈


mwah πŸ’‹ that's the page! brought to you by systemd 261.3 β€” go forth and check your init system, bestie, and remember: the header says SD_BOOTED(3) and so does the footer, because symmetry is main character energy βœ¨πŸ’…πŸŽ€

πŸ“¦ where this page comes from