commit 10a1415: [Minor] Block control signals on start

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Feb 9 15:07:07 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-02-09 15:03:12 +0000
URL: https://github.com/rspamd/rspamd/commit/10a141583005c5394e00b267cce7d6b7585d7c8e (HEAD -> master)

[Minor] Block control signals on start

---
 src/rspamd.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/rspamd.c b/src/rspamd.c
index e1b69fccd..4f035324d 100644
--- a/src/rspamd.c
+++ b/src/rspamd.c
@@ -1334,6 +1334,14 @@ main (gint argc, gchar **argv, gchar **env)
 	struct ev_loop *event_loop;
 	struct rspamd_main *rspamd_main;
 	gboolean skip_pid = FALSE;
+	sigset_t control_signals;
+
+	/* Block special signals on loading */
+	sigemptyset (&control_signals);
+	sigaddset (&control_signals, SIGHUP);
+	sigaddset (&control_signals, SIGUSR1);
+	sigaddset (&control_signals, SIGUSR2);
+	sigprocmask (SIG_BLOCK, &control_signals, NULL);
 
 	rspamd_main = (struct rspamd_main *) g_malloc0 (sizeof (struct rspamd_main));
 
@@ -1499,7 +1507,6 @@ main (gint argc, gchar **argv, gchar **env)
 		exit (-errno);
 	}
 
-	/* Block signals to use sigsuspend in future */
 	sigprocmask (SIG_BLOCK, &signals.sa_mask, NULL);
 
 	/* Set title */
@@ -1531,9 +1538,11 @@ main (gint argc, gchar **argv, gchar **env)
 			rspamd_main->cfg->history_file);
 	}
 
-	/* Spawn workers */
+	/* Init workers hash */
 	rspamd_main->workers = g_hash_table_new (g_direct_hash, g_direct_equal);
 
+	/* Unblock control signals */
+	sigprocmask (SIG_UNBLOCK, &control_signals, NULL);
 	/* Init event base */
 	event_loop = ev_default_loop (rspamd_config_ev_backend_get (rspamd_main->cfg));
 	rspamd_main->event_loop = event_loop;


More information about the Commits mailing list