summaryrefslogtreecommitdiff
path: root/initd/main.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-07 15:35:19 +0200
committerDavid Oberhollenzer <david.oberhollenzer@tele2.at>2018-04-07 16:19:38 +0200
commitb81668e045b6a2105b7b0b9e2e5afa8e631e6ec5 (patch)
tree6b37e483b49c52467a0ba1a62c416e2b5ada763f /initd/main.c
parent43274e3910d2a910262d1192e663db1d983f8e54 (diff)
Minor cleanup
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'initd/main.c')
-rw-r--r--initd/main.c25
1 files changed, 8 insertions, 17 deletions
diff --git a/initd/main.c b/initd/main.c
index 2be2045..192a49a 100644
--- a/initd/main.c
+++ b/initd/main.c
@@ -38,17 +38,14 @@ static void handle_exited(service_t *svc)
{
switch (svc->type) {
case SVC_RESPAWN:
- if (target == TGT_REBOOT || target == TGT_SHUTDOWN) {
- delsvc(svc);
+ if (target == TGT_REBOOT || target == TGT_SHUTDOWN)
break;
- }
if (svc->rspwn_limit > 0) {
svc->rspwn_limit -= 1;
if (svc->rspwn_limit == 0) {
print_status(svc->desc, STATUS_FAIL, false);
- delsvc(svc);
break;
}
}
@@ -56,20 +53,18 @@ static void handle_exited(service_t *svc)
svc->pid = runlst(svc->exec, svc->ctty);
if (svc->pid == -1) {
print_status(svc->desc, STATUS_FAIL, false);
- delsvc(svc);
+ break;
}
svclist_add(svc);
- break;
+ return;
case SVC_ONCE:
print_status(svc->desc,
svc->status == EXIT_SUCCESS ?
STATUS_OK : STATUS_FAIL, false);
- /* fall-through */
- default:
- delsvc(svc);
break;
}
+ delsvc(svc);
}
static void handle_signal(int sigfd)
@@ -86,11 +81,7 @@ static void handle_signal(int sigfd)
switch (info.ssi_signo) {
case SIGCHLD:
- for (;;) {
- pid = waitpid(-1, &status, WNOHANG);
- if (pid <= 0)
- break;
-
+ while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
status = WIFEXITED(status) ? WEXITSTATUS(status) :
EXIT_FAILURE;
@@ -132,9 +123,6 @@ static void start_runlevel(int level)
true);
delsvc(svc);
} else {
- if (svc->type == SVC_RESPAWN)
- print_status(svc->desc, STATUS_STARTED, false);
-
svc->pid = runlst(svc->exec, svc->ctty);
if (svc->pid == -1) {
print_status(svc->desc, STATUS_FAIL, false);
@@ -142,6 +130,9 @@ static void start_runlevel(int level)
continue;
}
+ if (svc->type == SVC_RESPAWN)
+ print_status(svc->desc, STATUS_STARTED, false);
+
svclist_add(svc);
}
}