RC_RUNLEVEL(3)

πŸ’– RC_RUNLEVEL β€” the runlevel functions, bestie πŸ’–

okay so this is rc_runlevel(3) from the System Manager's Manual β€” it lives in the Run Command library (that's librc, and you link it with -lrc), and it's the whole vibe for asking OpenRC "where am I and who's here". πŸ¦‹


✨ SYNOPSIS ✨

#include <rc.h>

char *
rc_runlevel_get(void);

bool
rc_runlevel_exists();

RC_STRINGLIST *
rc_runlevel_list(void);

bool
rc_runlevel_set(const char *runlevel);

bool
rc_runlevel_starting(void);

bool
rc_runlevel_stopping(void);

🌸 DESCRIPTION 🌸

These functions are literally your little group chat with OpenRC πŸ’… β€” they let you query it to find out which runlevel we're in, and what services are chilling in which runlevel. That's it, that's the whole job. Iconic behaviour, no notes.


πŸŽ€ IMPLEMENTATION NOTES πŸŽ€

⚠️ bestie, this part matters, do NOT skip it ⚠️
  • Every function that returns char * gives you back a malloced, NULL terminated string β€” and you should free it when you're done. It's not gonna clean itself up. Free your memory, queen. 😭
  • Every function that returns RC_STRINGLIST * should be freed by calling rc_stringlist_free() when you're done. Same energy, different function. 🫢

🧚 FILES 🧚

/etc/init.d/functions.sh is provided by OpenRC, and it's the thing that lets shell scripts use all of the above functions. slay. πŸ”₯

And now for a lil history lesson that's highkey a plot twist: for historical reasons, our verbose functions are prefixed with v instead of suffixed. So einfov becomes veinfo, and einfovn becomes veinfon. Rinse and repeat for the other verbose functions. Yeah. That's just how it is. Not me side-eyeing 2008-era naming conventions πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

malloc(3), free(3), rc_stringlist_free(3)


⭐ AUTHORS ⭐

Roy Marples <roy@marples.name>


okay and one last cute sign-off for you: this whole thing is OpenRC, and it's dated Mar 16, 2008 πŸ’œ so yes, she's a legend and she's been serving since 2008, and you're welcome for the lore. go free your mallocs, bestie πŸŽ€βœ¨

πŸ“¦ where this page comes from