aboutsummaryrefslogtreecommitdiff
path: root/initd/init.h
blob: 67d5fc4361261c98cdad1c3438ba3b0eaf76777b (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
67
68
69
70
71
72
/* 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/signalfd.h>
#include <sys/reboot.h>
#include <stdbool.h>
#include <signal.h>

#include "service.h"
#include "config.h"

#define ENVFILE ETCPATH "/initd.env"
#define PROCFDDIR "/proc/self/fd"

enum {
	STATUS_OK = 0,
	STATUS_FAIL,
	STATUS_WAIT,
	STATUS_STARTED,
};

/********** 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);

/********** status.c **********/

/*
	Print a status message. Type is either STATUS_OK, STATUS_FAIL,
	STATUS_WAIT or STATUS_STARTED.

	A new-line is appended to the mssage, UNLESS type is STATUS_WAIT.

	If update is true, print a carriage return first to overwrite the
	current line (e.g. after a STATUS_WAIT message).
*/
void print_status(const char *msg, int type, bool update);

/********** 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 */