/* SPDX-License-Identifier: ISC */ #ifndef INIT_H #define INIT_H #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "service.h" #include "config.h" #define ENVFILE ETCPATH "/initd.env" #define PROCFDDIR "/proc/self/fd" /* service run time data */ enum { STATE_OFF, STATE_RUNNING, STATE_QUEUED, STATE_COMPLETED, STATE_FAILED, }; typedef struct { service_t *svc; /* the underlying service description */ int state; /* what STATE_* the service is currently in */ int rspwn_count; /* services respawn counter */ int status; /* if exited, process exit status */ pid_t pid; /* if still running, the pid */ } svc_run_data_t; /********** main.c **********/ void target_completed(int target); /********** runsvc.c **********/ /* Invoke the runsvc command to execute the comands of a service. Returns the pid of the child process containing the runsvc instance. */ pid_t runsvc(service_t *svc); /********** supervisor.c **********/ void supervisor_handle_exited(pid_t pid, int status); void supervisor_set_target(int next); void supervisor_init(void); bool supervisor_process_queues(void); #endif /* INIT_H */