From 73d88e106fa0e85c5c2d100787fb640617b04798 Mon Sep 17 00:00:00 2001 From: turret Date: Tue, 16 Jan 2024 19:21:40 +0000 Subject: init: minor optimisations use switch{case} instead of if statements for determining action upon signal --- init/init.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'init/init.c') diff --git a/init/init.c b/init/init.c index 3fe370f..7fb229e 100644 --- a/init/init.c +++ b/init/init.c @@ -115,7 +115,8 @@ int main(void) while(subsystem_count > 0) { sigwaitinfo(&set, &siginfo); int sig = siginfo.si_signo; - if(sig == SIGCHLD) { + switch(sig) { + case SIGCHLD: ; int process = 0; while((process = waitpid(-1, NULL, WNOHANG)) > 0) if(subsystem_handle_term(process) > 0) @@ -124,10 +125,15 @@ int main(void) if(siginfo.si_status != 0) { panic("init: process %d exited with non-zero status (%d)", siginfo.si_pid, siginfo.si_status); } - } else if(sig == SIGINT) { + break; + case SIGINT: panic("init: keyboard interrupt"); - } else if(sig == SIGTERM) { + break; + case SIGTERM: exit(0); + break; + default: + break; } } -- cgit v1.2.3