diff options
author | David Oberhollenzer <goliath@infraroot.at> | 2020-05-13 19:45:39 +0200 |
---|---|---|
committer | David Oberhollenzer <goliath@infraroot.at> | 2020-05-14 01:26:14 +0200 |
commit | 22eb8fef6b6f0f836e08ab4ca92baab32e348257 (patch) | |
tree | b3ea4d30b5e4e9f0909bb403c592f29dfa0f910b | |
parent | f68692aa858a9b5ce17b0ab5f9ebe694f4ee12ab (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.c | 8 |
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); |