aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <goliath@infraroot.at>2020-05-13 19:45:39 +0200
committerDavid Oberhollenzer <goliath@infraroot.at>2020-05-14 01:26:14 +0200
commit22eb8fef6b6f0f836e08ab4ca92baab32e348257 (patch)
treeb3ea4d30b5e4e9f0909bb403c592f29dfa0f910b
parentf68692aa858a9b5ce17b0ab5f9ebe694f4ee12ab (diff)
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 <goliath@infraroot.at>
-rw-r--r--initd/main.c8
1 files changed, 8 insertions, 0 deletions
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);