From: Bart Van Assche Date: Sat, 12 Sep 2020 14:43:56 +0000 (-0700) Subject: helper_thread: Introduce a function for blocking Unix signals X-Git-Tag: fio-3.24~21^2~4 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=2575407ffec5a43ac55eba370a00243d368bcb8d;p=fio.git helper_thread: Introduce a function for blocking Unix signals This patch reworks commit c31092b8ac06 ("Block signals for the helper thread") but does not change any functionality. Signed-off-by: Bart Van Assche --- diff --git a/helper_thread.c b/helper_thread.c index c5ca23e0..88937ade 100644 --- a/helper_thread.c +++ b/helper_thread.c @@ -83,6 +83,18 @@ static int read_from_pipe(int fd, void *buf, size_t len) } #endif +static void block_signals(void) +{ +#ifdef HAVE_PTHREAD_SIGMASK + sigset_t sigmask; + + ret = pthread_sigmask(SIG_UNBLOCK, NULL, &sigmask); + assert(ret == 0); + ret = pthread_sigmask(SIG_BLOCK, &sigmask, NULL); + assert(ret == 0); +#endif +} + static void submit_action(enum action a) { const char data = a; @@ -157,17 +169,8 @@ static void *helper_thread_main(void *data) sk_out_assign(hd->sk_out); -#ifdef HAVE_PTHREAD_SIGMASK - { - sigset_t sigmask; - /* Let another thread handle signals. */ - ret = pthread_sigmask(SIG_UNBLOCK, NULL, &sigmask); - assert(ret == 0); - ret = pthread_sigmask(SIG_BLOCK, &sigmask, NULL); - assert(ret == 0); - } -#endif + block_signals(); fio_get_mono_time(&ts); memcpy(&last_du, &ts, sizeof(ts));