From 387532c3572824333550880d7b73d879ceb6a871 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 13 May 2020 17:50:16 +0200 Subject: Move the rest of the main loop into supervisor_process_queues Signed-off-by: David Oberhollenzer --- initd/init.h | 2 +- initd/main.c | 14 +------------- initd/supervisor.c | 11 +++++++---- 3 files changed, 9 insertions(+), 18 deletions(-) (limited to 'initd') diff --git a/initd/init.h b/initd/init.h index ad681d9..bfc1f62 100644 --- a/initd/init.h +++ b/initd/init.h @@ -62,6 +62,6 @@ void supervisor_set_target(int next); void supervisor_init(void); -bool supervisor_process_queues(void); +void supervisor_process_queues(void); #endif /* INIT_H */ diff --git a/initd/main.c b/initd/main.c index 2d721a4..446553c 100644 --- a/initd/main.c +++ b/initd/main.c @@ -20,8 +20,6 @@ static void handle_signal(int signo) int main(void) { struct sigaction act; - int status; - pid_t pid; supervisor_init(); @@ -37,17 +35,7 @@ int main(void) perror("cannot disable CTRL+ALT+DEL"); for (;;) { - while (supervisor_process_queues()) - ; - - pid = wait(&status); - - if (pid != -1) { - status = WIFEXITED(status) ? - WEXITSTATUS(status) : EXIT_FAILURE; - - supervisor_handle_exited(pid, status); - } + supervisor_process_queues(); } return EXIT_SUCCESS; diff --git a/initd/supervisor.c b/initd/supervisor.c index c1b44e7..d54b9ca 100644 --- a/initd/supervisor.c +++ b/initd/supervisor.c @@ -185,7 +185,7 @@ static pid_t wait_for_process(int *status) return pid; } -bool supervisor_process_queues(void) +void supervisor_process_queues(void) { svc_run_data_t *rt; service_t *svc; @@ -194,8 +194,12 @@ bool supervisor_process_queues(void) pid_t pid; count = queue_count[target]; - if (queue_idx >= count) - return false; + + if (queue_idx >= count) { + pid = wait_for_process(&status); + supervisor_handle_exited(pid, status); + return; + } rt = rt_data + queue_start[target] + queue_idx++; svc = rt->svc; @@ -235,5 +239,4 @@ bool supervisor_process_queues(void) } check_target_completion(); - return true; } -- cgit v1.2.3