DOKK / manpages / debian 10 / librc-dev / rc_service.3.en
RC_SERVICE(3) Library Functions Manual (smm) RC_SERVICE(3)

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_crashedfunctions to query OpenRC services

Run Command library (librc, -lrc)

#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);

These functions provide a means of querying OpenRC services to find out the state of each one, to start and stop it, and any other functions related to it.

Most functions should be self descriptive as to what they do and what they return based on names and arguments.

() adds the service to the runlevel.

() deletes the service from the runlevel.

() saves the arguments in the service state data so that () can check to see if they are still running or not.

() returns the description variable of the service. If option is not null then we return the description_$option variable instead.

() returns true if the service exists, otherwise false.

() returns true if the service is in the runlevel, otherwise false.

() puts the service into the given state. If the state is RC_SERVICE_STOPPED then all data associated with the service is lost. () returns a list of extra commands the service supports beyond the default ones. See openrc-run for default commands.

() returns true if the service is allowed to be plugged by rc.conf. Default is true.

() resolves service to the full path of service that was started, or would be started.

When service starts, it starts service_to_start afterswards as directed by (). () returns a list of services that will be started when service starts. () clears these scheduled services for service.

(returns, the, state, of) service. The return value is a bitmask, where more than one state can apply.

() checks to see if service started exec using start-stop-daemon. If indx is greater than zero, then it must also be the nth daemon started by service. () saves the value under the name option. () returns the value of the saved option.

() returns a list of services in runlevel. If runlevel is not specified, then it returns a list of all available services.

() returns a list of all the services in state.

Each function that returns char * returns a malloced NULL terminated string that should be freed when done.

Each function that returns RC_STRINGLIST * should be freed using rc_stringlist_free() when done.

When a function fails it should either return false or NULL and set errno unless specified otherwise as above.

/lib/rc/init.d normally holds the volatile state data for services on a RAM backed disk.

errno(3), malloc(3), free(3) rc_stringlist_free(3), start-stop-daemon(8)

Roy Marples <roy@marples.name>

March 16, 2008 OpenRC