From 0e31829401c78c36a8e473091644c12d04742370 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Wed, 2 Aug 2023 23:34:10 +0200 Subject: nDPId-test: threads should block all unix signals Signed-off-by: Toni Uhlig --- nDPId-test.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/nDPId-test.c b/nDPId-test.c index 836d0b347..8e8870a8a 100644 --- a/nDPId-test.c +++ b/nDPId-test.c @@ -241,6 +241,14 @@ static int thread_wait(struct thread_condition * const tc) return ret; } +static int thread_block_signals() +{ + sigset_t blocked_signals; + + sigfillset(&blocked_signals); + return pthread_sigmask(SIG_BLOCK, &blocked_signals, NULL); +} + static int thread_signal(struct thread_condition * const tc) { int ret = 0; @@ -294,6 +302,11 @@ static void * nDPIsrvd_mainloop_thread(void * const arg) logger(0, "nDPIsrvd thread started, init.."); + if (thread_block_signals() != 0) + { + logger(1, "nDPIsrvd block signals failed: %s", strerror(errno)); + } + errno = 0; epollfd = create_evq(); if (epollfd < 0) @@ -857,6 +870,11 @@ static void * distributor_client_mainloop_thread(void * const arg) logger(0, "Distributor thread started, init.."); + if (thread_block_signals() != 0) + { + logger(1, "Distributor block signals failed: %s", strerror(errno)); + } + errno = 0; if (mock_sock == NULL || mock_buff == NULL || mock_null == NULL) { @@ -1170,6 +1188,11 @@ static void * nDPId_mainloop_thread(void * const arg) logger(0, "nDPId thread started, init.."); + if (thread_block_signals() != 0) + { + logger(1, "nDPId block signals failed: %s", strerror(errno)); + } + if (setup_reader_threads() != 0) { THREAD_ERROR(trr); -- cgit v1.2.3