From 7e35c7e1de06509fff64b3710630a0f16fd50a04 Mon Sep 17 00:00:00 2001 From: Yasushi SHOJI Date: Mon, 20 Mar 2023 10:07:33 +0900 Subject: [PATCH] canfdtest: Follow Bash exit status when signaled Bash and many other shells use 128 + signum as the exit status when a program get signal and exit. Follow the common behavior so that we know how the programs are killed. canfdtest.c was effectively raising the received signal again to run the default signal handler. This has been declined by the maintainer because it's over-engineering. This commit replaces it with the method proposed by the maintainer. Signed-off-by: Yasushi SHOJI --- canfdtest.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/canfdtest.c b/canfdtest.c index a5050bc..d47727f 100644 --- a/canfdtest.c +++ b/canfdtest.c @@ -584,10 +584,8 @@ int main(int argc, char *argv[]) close(sockfd); - if (exit_sig) { - signal(exit_sig, SIG_DFL); - kill(getpid(), exit_sig); - } + if (exit_sig) + return 128 + exit_sig; return err; }