canlogserver: Fix termination after signal

With f45de1b782, 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: f45de1b782 ("canlogserver: Follow Bash exit status when signaled")

Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
pull/423/head
Yasushi SHOJI 2023-04-06 18:14:20 +09:00
parent c8fef7d60d
commit 0d276a105d
1 changed files with 9 additions and 0 deletions

View File

@ -306,6 +306,15 @@ int main(int argc, char **argv)
perror("accept"); perror("accept");
exit(1); exit(1);
} }
else if ((errno == EINTR) && !running) {
close(socki);
if (signal_num) {
return 128 + signal_num;
}
else {
return 1;
}
}
} }
for (i=0; i<currmax; i++) { for (i=0; i<currmax; i++) {