RC_SERVICE(3)
π RC_SERVICE(3) β the OpenRC service-querying girlies π
okay so. bestie. this is a page from the System Manager's Manual, and it's librc's whole little toolkit for asking OpenRC services how they're doing. no cap, it's giving "group chat but for daemons". let's get into it π
β¨ NAME β¨
rc_service_add, rc_service_delete, rc_service_daemon_set, rc_service_description, rc_service_exists, rc_service_in_runlevel, rc_service_mark, rc_service_extra_commands, rc_service_plugable, rc_service_resolve, rc_service_schedule_start, rc_services_scheduled_by, rc_service_schedule_clear, rc_service_state, rc_service_started_daemon, rc_service_value_get, rc_service_value_set, rc_services_in_runlevel, rc_services_in_state, rc_services_scheduled, rc_service_daemons_crashed β functions to query OpenRC services π
π LIBRARY π
Run Command library (librc, -lrc) π«Ά
πΈ SYNOPSIS πΈ
#include <rc.h>
bool
rc_service_add(const char *runlevel, const char *service);
bool
rc_service_delete(const char *runlevel, const char *service);
bool
rc_service_daemon_set(const char *service, const char *exec,
const char *name, const char *pidfile, bool started);
char *
rc_service_description(const char *service, const char *option);
bool
rc_service_exists(const char *service);
bool
rc_service_in_runlevel(const char *service, const char *runlevel);
bool
rc_service_mark(const char *service, RC_SERVICE state);
RC_STRINGLIST *
rc_service_extra_commands(const char *service);
bool
rc_service_plugable(const char *service);
char * rc_service_resolve const char *service
bool
rc_service_schedule_start(const char *service,
const char *service_to_start);
RC_STRINGLIST *
rc_services_scheduled_by(const char *service);
bool
rc_service_schedule_clear(const char *service);
RC_SERVICE
rc_service_state(const char *service);
bool
rc_service_started_daemon(const char *service, const char *exec,
int indx);
char *
rc_service_value_get(const char *service, const char *option);
bool
rc_service_value_set(const char *service, const char *option,
const char *value);
RC_STRINGLIST *
rc_services_in_runlevel(const char *runlevel);
RC_STRINGLIST *
rc_services_in_state(RC_SERVICE state);
RC_STRINGLIST *
rc_services_scheduled(const char *service);
bool
rc_service_daemons_crashed(const char *service);
iykyk β yes,rc_service_resolveandrc_service_statelook a lil cursed up there in the synopsis. we are reproducing them exactly, character for character, because that's the vibe. don't come for me, come for the header file π
π DESCRIPTION π
these functions are the way you ~query~ OpenRC services: find out what state each one is in, start and stop it, and do all the other lil related things. main character energy for your init system, fr fr.
most of them are exactly what they sound like β the name and the arguments tell you what they do and what they hand back. self-descriptive icons, we love that for them β¨
rc_service_add()β adds the service to the runlevel. πrc_service_delete()β deletes the service from the runlevel. bye bestie π¦rc_service_daemon_set()β saves the arguments in the service state data, so thatrc_service_daemons_crashed()can go check whether they're still running or not. it's the receipts-keeper. π§Ύrc_service_description()β returns thedescriptionvariable of the service. and if option is not null? then we return thedescription_$optionvariable instead. plot twist, but make it useful. πrc_service_exists()β returnstrueif the service exists, otherwisefalse. simple as.rc_service_in_runlevel()β returnstrueif the service is in the runlevel, otherwisefalse.rc_service_mark()β puts the service into the given state. β οΈ and heads up: if the state isRC_SERVICE_STOPPEDthen all data associated with the service is lost. that's not a drill, that's data loss, so know what you're doing before you mark. πrc_service_extra_commands()β returns a list of extra commands the service supports beyond the default ones. (for what the default ones are, go seeopenrc-run.) πrc_service_plugable()β returnstrueif the service is allowed to be plugged byrc.conf. default istrue. π«Άrc_service_resolve()β resolves service to the full path of the service that was started, or would be started. β¨- the scheduling trio, besties: when service starts, it starts service_to_start afterwards as directed by
rc_service_schedule_start().rc_services_scheduled()returns a list of services that will be started when service starts.rc_service_schedule_clear()clears these scheduled services for service. it's a whole chain reaction and honestly? iconic. π₯ rc_service_state()β returns the state of service. the return value is a bitmask, so more than one state can apply at once. not either/or, it's a whole spectrum, we support that πrc_service_started_daemon()β checks to see if service started exec usingstart-stop-daemon. and if indx is greater than zero, then it must also be the nth daemon started by service. very specific. very demure.rc_service_value_set()β saves the value under the name option.rc_service_value_get()returns the value of the saved option. β¨rc_services_in_runlevel()β returns a list of services in runlevel. and if runlevel is not specified? then it returns a list of all available services. generous queen πrc_services_in_state()β returns a list of all the services in state. π¦
little note for the completionists: rc_services_scheduled_by() shows up in the NAME list and in the SYNOPSIS, but the DESCRIPTION section lowkey never gives it its own sentence. so it's here, bestie β we did not lose it. π
π οΈ IMPLEMENTATION NOTES π οΈ
- every function that returns
char *returns amallocedNULLterminated string, and you shouldfree()it when you're done. no leaking, we're better than that. π - every function that returns
RC_STRINGLIST *should be freed usingrc_stringlist_free()when you're done. π - when a function fails it should either return
falseorNULLand seterrnoβ unless it's specified otherwise, like, above. so checkerrno, bestie. it's the receipts. π§Ύ
ποΈ FILES ποΈ
/run/openrcβ normally holds the volatile state data for services on a RAM backed disk. yes, RAM. yes, it can vanish. that's the whole point, it's a vibe. π
π SEE ALSO π
errno(3), malloc(3), free(3), rc_stringlist_free(3), start-stop-daemon(8) πΈ
π AUTHORS π
Roy Marples <roy@marples.name> β the original main character, respect. π«Ά
and that's the page, babe. this one shipped under OpenRC, dated Mar 16, 2008, and honestly it ate. go forth and query your services responsibly. periodt. πβ¨ππ¦
π¦ 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 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