#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.
*
static void
register_signal_handlers(void)
{
-#ifdef BACKTRACE_ENABLED
struct sigaction action;
+
+#ifdef BACKTRACE_ENABLED
void* dummy;
/*
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
}
#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:
*
* 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.
*/
pr_op_err("SIGPIPE handler registration failure: %s",
strerror(errno));
- }
}
int