From 4c4489a539ca902aa55e8a01c8836047a8becc77 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Wed, 31 Jul 2024 18:57:15 +0200 Subject: [PATCH] Use pipe to main process instead of printing directly from the signal handler to avoid futex wait blocking Signed-off-by: DL6ER --- src/dnsmasq/dnsmasq.c | 11 ++++++++++- src/dnsmasq/dnsmasq.h | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/dnsmasq/dnsmasq.c b/src/dnsmasq/dnsmasq.c index cfcb38da..e051d3e2 100644 --- a/src/dnsmasq/dnsmasq.c +++ b/src/dnsmasq/dnsmasq.c @@ -1310,7 +1310,10 @@ int main_dnsmasq (int argc, char **argv) static void sig_handler(int sig) { - log_debug(DEBUG_ANY, "dnsmasq received signal %d", sig); + /**** Pi-hole modification ****/ + send_event(pipewrite, EVENT_SIGNAL, sig, NULL); + /******************************/ + if (pid == 0) { /* ignore anything other than TERM during startup @@ -1570,6 +1573,12 @@ static void async_event(int pipe, time_t now) my_syslog(LOG_WARNING, _("script process exited with status %d"), ev.data); break; + /**** Pi-hole modification ****/ + case EVENT_SIGNAL: + log_debug(DEBUG_ANY, "dnsmasq received signal %d", ev.data); + break; + /**************************** */ + case EVENT_EXEC_ERR: my_syslog(LOG_ERR, _("failed to execute %s: %s"), daemon->lease_change_command, strerror(ev.data)); diff --git a/src/dnsmasq/dnsmasq.h b/src/dnsmasq/dnsmasq.h index a16c83b4..ce8d1d09 100644 --- a/src/dnsmasq/dnsmasq.h +++ b/src/dnsmasq/dnsmasq.h @@ -200,6 +200,9 @@ struct event_desc { #define EVENT_SCRIPT_LOG 25 #define EVENT_TIME 26 +// Pi-hole +#define EVENT_SIGNAL 255 + /* Exit codes. */ #define EC_GOOD 0 #define EC_BADCONF 1