diff options
-rw-r--r-- | initd/main.c | 23 | ||||
-rw-r--r-- | initd/runsvc.c | 1 | ||||
-rw-r--r-- | initd/supervisor.c | 13 |
3 files changed, 13 insertions, 24 deletions
diff --git a/initd/main.c b/initd/main.c index 5ad265d..2d721a4 100644 --- a/initd/main.c +++ b/initd/main.c @@ -3,18 +3,7 @@ static void handle_signal(int signo) { - int status; - pid_t pid; - switch (signo) { - case SIGCHLD: - while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { - status = WIFEXITED(status) ? WEXITSTATUS(status) : - EXIT_FAILURE; - - supervisor_handle_exited(pid, status); - } - break; case SIGTERM: supervisor_set_target(TGT_SHUTDOWN); break; @@ -31,13 +20,14 @@ static void handle_signal(int signo) int main(void) { struct sigaction act; + int status; + pid_t pid; supervisor_init(); memset(&act, 0, sizeof(act)); act.sa_handler = handle_signal; - sigaction(SIGCHLD, &act, NULL); sigaction(SIGTERM, &act, NULL); sigaction(SIGINT, &act, NULL); sigaction(SIGHUP, &act, NULL); @@ -50,7 +40,14 @@ int main(void) while (supervisor_process_queues()) ; - pause(); + pid = wait(&status); + + if (pid != -1) { + status = WIFEXITED(status) ? + WEXITSTATUS(status) : EXIT_FAILURE; + + supervisor_handle_exited(pid, status); + } } return EXIT_SUCCESS; diff --git a/initd/runsvc.c b/initd/runsvc.c index 95c26cb..df5a656 100644 --- a/initd/runsvc.c +++ b/initd/runsvc.c @@ -204,7 +204,6 @@ pid_t runsvc(service_t *svc) sigaction(SIGHUP, &act, NULL); act.sa_handler = SIG_DFL; - sigaction(SIGCHLD, &act, NULL); sigaction(SIGUSR1, &act, NULL); if (setup_env()) diff --git a/initd/supervisor.c b/initd/supervisor.c index 43900a5..5849b9c 100644 --- a/initd/supervisor.c +++ b/initd/supervisor.c @@ -180,23 +180,18 @@ out: bool supervisor_process_queues(void) { svc_run_data_t *rt; - sigset_t old_mask; service_t *svc; size_t count; - bool ret = false; - - cli(&old_mask); if (waiting) - goto out_unblock; + return false; count = queue_count[target]; if (queue_idx >= count) - goto out_unblock; + return false; rt = rt_data + queue_start[target] + queue_idx++; svc = rt->svc; - ret = true; if (svc->flags & SVC_FLAG_HAS_EXEC) { rt->pid = runsvc(rt->svc); @@ -222,7 +217,5 @@ bool supervisor_process_queues(void) print_status(svc->desc, rt->state); check_target_completion(); -out_unblock: - sti(&old_mask); - return ret; + return true; } |