aboutsummaryrefslogtreecommitdiff
path: root/initd
diff options
context:
space:
mode:
authorDavid Oberhollenzer <goliath@infraroot.at>2019-03-18 18:38:27 +0100
committerDavid Oberhollenzer <goliath@infraroot.at>2019-03-18 18:47:20 +0100
commita9602ad6e018afd7621052e1263d3cae0e6da5f3 (patch)
tree55f702e36171f58112b9fc05c1d9d393e643bddf /initd
parent3f40c4d3ed5d13e98a92773a475883237c3b549b (diff)
Cleanup status reporting
- mimic format of initd - skip formatting if not a tty - distinguish exited because failed vs exited because done Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'initd')
-rw-r--r--initd/supervisor.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/initd/supervisor.c b/initd/supervisor.c
index 3743ad6..cd38469 100644
--- a/initd/supervisor.c
+++ b/initd/supervisor.c
@@ -8,6 +8,7 @@ static service_t *running = NULL;
static service_t *terminated = NULL;
static service_t *queue = NULL;
static service_t *completed = NULL;
+static service_t *failed = NULL;
static int singleshot = 0;
static bool waiting = false;
@@ -38,7 +39,7 @@ static void handle_terminated_service(service_t *svc)
if (svc->rspwn_limit == 0) {
print_status(svc->desc, STATUS_FAIL, false);
- break;
+ goto out_failure;
}
}
@@ -51,6 +52,8 @@ static void handle_terminated_service(service_t *svc)
STATUS_OK : STATUS_FAIL, true);
if (singleshot == 0 && queue == NULL)
target_completed(target);
+ if (svc->status != EXIT_SUCCESS)
+ goto out_failure;
break;
case SVC_ONCE:
singleshot -= 1;
@@ -59,10 +62,16 @@ static void handle_terminated_service(service_t *svc)
STATUS_OK : STATUS_FAIL, false);
if (singleshot == 0 && queue == NULL && !waiting)
target_completed(target);
+ if (svc->status != EXIT_SUCCESS)
+ goto out_failure;
break;
}
svc->next = completed;
completed = svc;
+ return;
+out_failure:
+ svc->next = failed;
+ failed = svc;
}
void supervisor_handle_exited(pid_t pid, int status)
@@ -185,7 +194,9 @@ void supervisor_answer_status_request(int fd, const void *dst, size_t addrlen)
{
if (send_svc_list(fd, dst, addrlen, ESS_RUNNING, running))
return;
- if (send_svc_list(fd, dst, addrlen, ESS_EXITED, completed))
+ if (send_svc_list(fd, dst, addrlen, ESS_DONE, completed))
+ return;
+ if (send_svc_list(fd, dst, addrlen, ESS_FAILED, failed))
return;
if (send_svc_list(fd, dst, addrlen, ESS_ENQUEUED, queue))
return;