From a0b48b8ac0aae002aabe9193add163c6eefcb374 Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Fri, 7 Sep 2018 10:50:21 +0200 Subject: [PATCH] canfdtest: don't remap SIG to 0 Scripts can be configured to handle different SIGnals and return codes in different ways. In this case it is better to forward received signal, instead of converting it to return 0. Signed-off-by: Oleksij Rempel --- canfdtest.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/canfdtest.c b/canfdtest.c index 5592541..9b51c85 100644 --- a/canfdtest.c +++ b/canfdtest.c @@ -47,6 +47,7 @@ static int running = 1; static int verbose; static int sockfd; static int test_loops; +static int exit_sig = 0; static void print_usage(char *prg) { @@ -149,6 +150,7 @@ static void signal_handler(int signo) { close(sockfd); running = 0; + exit_sig = signo; } static int recv_frame(struct can_frame *frame) @@ -355,5 +357,11 @@ int main(int argc, char *argv[]) printf("Exiting...\n"); close(sockfd); + + if (exit_sig) { + signal(exit_sig, SIG_DFL); + kill(getpid(), exit_sig); + } + return err; }