diff options
Diffstat (limited to 'init/init.c')
-rw-r--r-- | init/init.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/init/init.c b/init/init.c index 5387043..3fe370f 100644 --- a/init/init.c +++ b/init/init.c @@ -62,6 +62,8 @@ static void do_initcalls(void) } } + + int main(void) { print("init: Hello world! Running " NAME " v" VERSION "!"); @@ -78,6 +80,15 @@ int main(void) } free(stack_rlimit); + /* configure signal handlers early to prevent race condition where subsystems + can terminate main process on accident, and disable Terminated output during + early-mode panic */ + static sigset_t set; + sigaddset(&set, SIGCHLD); + sigaddset(&set, SIGINT); + sigaddset(&set, SIGTERM); + sigprocmask(SIG_BLOCK, &set, NULL); + /* fetch token */ char *token_base = getenv("TOKEN"); if(!token_base) @@ -99,13 +110,8 @@ int main(void) do_initcalls(); /* Reaper. Much like init. */ - siginfo_t siginfo; - static sigset_t set; - sigaddset(&set, SIGCHLD); - sigaddset(&set, SIGINT); - sigaddset(&set, SIGTERM); - sigprocmask(SIG_BLOCK, &set, NULL); + siginfo_t siginfo; while(subsystem_count > 0) { sigwaitinfo(&set, &siginfo); int sig = siginfo.si_signo; |