From 22eb8fef6b6f0f836e08ab4ca92baab32e348257 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Wed, 13 May 2020 19:45:39 +0200 Subject: initd: propperly handle error cases for wait() If we are interrupted by a signal, the target might have changed and we really, really have to return to the main loop. If wait failed because all children are dead, something went horribly wrong. There is NO POSSIBLE WAY to get out of this state and the best thing we can do is exit, to trigger a kernel panic. Signed-off-by: David Oberhollenzer --- initd/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/initd/main.c b/initd/main.c index d8319ea..b83beb3 100644 --- a/initd/main.c +++ b/initd/main.c @@ -64,6 +64,14 @@ static svc_run_data_t *wait_for_process(void) do { pid = wait(&status); + if (pid == -1) { + if (errno == EINTR) + return NULL; + + if (errno == ECHILD) + exit(EXIT_FAILURE); + } + rt = config_rt_data_by_pid(pid); } while (rt == NULL); -- cgit v1.2.3