blob: 005fbbaacb6284e76411ffa781870ac9fee7c0df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* SPDX-License-Identifier: ISC */
#ifndef INIT_H
#define INIT_H
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <endian.h>
#include <stdio.h>
#include <errno.h>
#include <poll.h>
#include <linux/reboot.h>
#include <sys/reboot.h>
#include <sys/prctl.h>
#include <stdbool.h>
#include <signal.h>
#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;
/********** 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 */
|