From 0d276a105d0e76acef8609f2772538d6141db0b4 Mon Sep 17 00:00:00 2001 From: Yasushi SHOJI Date: Thu, 6 Apr 2023 18:14:20 +0900 Subject: [PATCH] canlogserver: Fix termination after signal With f45de1b782c083, we've removed unsafe function exit(3) from the signal handler. But that made canlogserver's accept(3)ing process not exit; It unconditionally keeps running with EINTR. Check the variable "running" when signaled and exit with an appropriate error code. Fixes: f45de1b782c0 ("canlogserver: Follow Bash exit status when signaled") Signed-off-by: Yasushi SHOJI --- canlogserver.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/canlogserver.c b/canlogserver.c index aa41347..3fe1ad9 100644 --- a/canlogserver.c +++ b/canlogserver.c @@ -306,6 +306,15 @@ int main(int argc, char **argv) perror("accept"); exit(1); } + else if ((errno == EINTR) && !running) { + close(socki); + if (signal_num) { + return 128 + signal_num; + } + else { + return 1; + } + } } for (i=0; i