aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorturret <turret@duck.com>2024-01-16 19:21:40 +0000
committerturret <turret@duck.com>2024-01-16 19:21:40 +0000
commit73d88e106fa0e85c5c2d100787fb640617b04798 (patch)
tree22f76c70f460fafbb78d04fdea117d6d7325268f
parent5e46528be9b1f0efcb4b3abf2033d6a37432f248 (diff)
downloaddiscord-bot-skeleton-73d88e106fa0e85c5c2d100787fb640617b04798.tar.gz
discord-bot-skeleton-73d88e106fa0e85c5c2d100787fb640617b04798.tar.bz2
discord-bot-skeleton-73d88e106fa0e85c5c2d100787fb640617b04798.zip
init: minor optimisations
use switch{case} instead of if statements for determining action upon signal
-rw-r--r--init/init.c12
1 files changed, 9 insertions, 3 deletions
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;
}
}