diff options
author | David Oberhollenzer <goliath@infraroot.at> | 2020-05-13 17:50:16 +0200 |
---|---|---|
committer | David Oberhollenzer <goliath@infraroot.at> | 2020-05-13 17:52:55 +0200 |
commit | 387532c3572824333550880d7b73d879ceb6a871 (patch) | |
tree | 2626eda80eb3eae6e877b852e9f9ad2abdfc563e /initd | |
parent | 353f7a7bbbf612cdae0fe00a4add739d5316c8a2 (diff) |
Move the rest of the main loop into supervisor_process_queues
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
Diffstat (limited to 'initd')
-rw-r--r-- | initd/init.h | 2 | ||||
-rw-r--r-- | initd/main.c | 14 | ||||
-rw-r--r-- | initd/supervisor.c | 11 |
3 files changed, 9 insertions, 18 deletions
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; } |