From: Alberto Leiva Popper Date: Tue, 17 Mar 2026 21:34:24 +0000 (-0300) Subject: Fire up validation when SIGUSR1 is received while sleeping X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d24d824f781a0804268d1fbfda1c21f0653e72b4;p=thirdparty%2FFORT-validator.git Fire up validation when SIGUSR1 is received while sleeping Tentatively fixes #42, except it applies on SIGUSR1, not SIGHUP. I don't understand the logic of using SIGHUP for this. --- diff --git a/src/log.c b/src/log.c index ecff284e..0b12ce19 100644 --- a/src/log.c +++ b/src/log.c @@ -144,6 +144,18 @@ sigsegv_handler(int signum) #endif +static void +sigusr1_handler(int signum) +{ + /* + * Nothing. + * We want to wake up the main thread's sleep(), but according to its + * documentation, that happens automatically. + * All we had to do was set up SIGUSR1 so it's neither ignored nor + * results in program termination. + */ +} + /* * Register better handlers for some signals. * @@ -152,8 +164,9 @@ sigsegv_handler(int signum) static void register_signal_handlers(void) { -#ifdef BACKTRACE_ENABLED struct sigaction action; + +#ifdef BACKTRACE_ENABLED void* dummy; /* @@ -167,7 +180,6 @@ register_signal_handlers(void) memset(&action, 0, sizeof(action)); action.sa_handler = sigsegv_handler; sigemptyset(&action.sa_mask); - action.sa_flags = 0; if (sigaction(SIGSEGV, &action, NULL) == -1) { /* * Not fatal; it just means we will not print stack traces on @@ -178,6 +190,14 @@ register_signal_handlers(void) } #endif + /* SIGUSR1 handler */ + memset(&action, 0, sizeof(action)); + action.sa_handler = sigusr1_handler; + sigemptyset(&action.sa_mask); + if (sigaction(SIGUSR1, &action, NULL) == -1) + pr_op_err("SIGUSR1 handler registration failure: %s", + strerror(errno)); + /* * SIGPIPE can be triggered by any I/O function. libcurl is particularly * tricky: @@ -196,7 +216,10 @@ register_signal_handlers(void) * * https://github.com/NICMx/FORT-validator/issues/49 */ - if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) { + memset(&action, 0, sizeof(action)); + action.sa_handler = SIG_IGN; + sigemptyset(&action.sa_mask); + if (sigaction(SIGPIPE, &action, NULL) == -1) /* * Not fatal. It just means that, if a broken pipe happens, we * will die silently. @@ -204,7 +227,6 @@ register_signal_handlers(void) */ pr_op_err("SIGPIPE handler registration failure: %s", strerror(errno)); - } } int