aboutsummaryrefslogtreecommitdiff
path: root/initd/main.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-22 01:02:27 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-22 13:41:18 +0200
commit59731dd69bb4be66c721b3de66fb2ab80bec3e7e (patch)
treea5b17b8d95c1ffeb4b3312893be3bb9567b64363 /initd/main.c
parent720220a3c3c42b92734e2a92f9094348451e187b (diff)
Add helper program for running services
We no longer need to keep entire scripts in init program (i.e. saving space) and reduce the code and complexity of the init program. The runsvc tool can later be extended to do more complex child setup, such as configuring namespaces or seccomp without adding complexity or memory footprint to init. Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'initd/main.c')
-rw-r--r--initd/main.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/initd/main.c b/initd/main.c
index a1d6906..8adbe2f 100644
--- a/initd/main.c
+++ b/initd/main.c
@@ -48,7 +48,7 @@ static void handle_exited(service_t *svc)
}
}
- svc->pid = runlst(svc->exec, svc->ctty);
+ svc->pid = runsvc(svc);
if (svc->pid == -1) {
print_status(svc->desc, STATUS_FAIL, false);
break;
@@ -104,16 +104,10 @@ static void start_runlevel(int level)
svc = cfg.targets[level];
cfg.targets[level] = svc->next;
- if (svc->exec == NULL) {
- print_status(svc->desc, STATUS_OK, false);
- delsvc(svc);
- continue;
- }
-
if (svc->type == SVC_WAIT) {
print_status(svc->desc, STATUS_WAIT, false);
- status = runlst_wait(svc->exec, svc->ctty);
+ status = runsvc_wait(svc);
print_status(svc->desc,
status == EXIT_SUCCESS ?
@@ -121,7 +115,7 @@ static void start_runlevel(int level)
true);
delsvc(svc);
} else {
- svc->pid = runlst(svc->exec, svc->ctty);
+ svc->pid = runsvc(svc);
if (svc->pid == -1) {
print_status(svc->desc, STATUS_FAIL, false);
delsvc(svc);
@@ -193,7 +187,7 @@ int main(void)
return EXIT_FAILURE;
}
- if (svcscan(SVCDIR, &cfg, 0)) {
+ if (svcscan(SVCDIR, &cfg, RDSVC_NO_EXEC | RDSVC_NO_CTTY)) {
fputs("Error reading service list from " SVCDIR "\n"
"Trying to continue anyway\n", stderr);
}