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 callingrc_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
- alpine 3.22: openrc-doc 0.62.6-r0 Β· BSD-2-Clause
- alpine 3.23: openrc-doc 0.63-r1 Β· BSD-2-Clause
- alpine 3.24: openrc-doc 0.63.2-r0 Β· BSD-2-Clause
- debian bookworm: librc-dev 0.45.2-2+deb12u1 Β· BSD-2-clauses
- debian trixie: librc-dev 0.56-1 Β· BSD-2-clauses
- Copyright (c) 2007-2015 The OpenRC Authors
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms