From 43e46cf01394a0f45860595d4c20c84d2f7e82f3 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 8 Feb 2026 15:44:20 +0100 Subject: [PATCH] When received a signal, terminate with the same signal --- cmdline/snapraid.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cmdline/snapraid.c b/cmdline/snapraid.c index 18400940..9e4b200d 100644 --- a/cmdline/snapraid.c +++ b/cmdline/snapraid.c @@ -908,10 +908,8 @@ volatile int global_interrupt = 0; /* LCOV_EXCL_START */ void signal_handler(int signum) { - (void)signum; - - /* report the request of interruption */ - global_interrupt = 1; + /* report the request of interruption with the signal received */ + global_interrupt = signum; } /* LCOV_EXCL_STOP */ @@ -2005,7 +2003,14 @@ int snapraid_main(int argc, char* argv[]) #ifdef _WIN32 exit(STATUS_CONTROL_C_EXIT); #else - exit(128 + SIGINT); + /* restore default handler */ + signal(global_interrupt, SIG_DFL); + + /* raise the signal again*/ + raise(global_interrupt); + + /* if raise() didn't terminate */ + _exit(128 + global_interrupt); #endif /* LCOV_EXCL_STOP */ }