From: Bart Van Assche Date: Sat, 4 Jan 2020 21:58:52 +0000 (-0800) Subject: Block signals for the helper thread X-Git-Tag: fio-3.18~22^2~3 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=c31092b8ac06d845f3022339f55f482308e02b6e;p=fio.git Block signals for the helper thread Let another thread than the helper thread handle signals. This simplifies error handling. As an example, the next patch will check the return value of select() and won't have to check for EINTR due to this patch. Signed-off-by: Bart Van Assche --- diff --git a/configure b/configure index 2671c325..fa6df532 100755 --- a/configure +++ b/configure @@ -726,6 +726,27 @@ elif compile_prog "" "$LIBS -lpthread" "pthread_condattr_setclock" ; then fi print_config "pthread_condattr_setclock()" "$pthread_condattr_setclock" +########################################## +# pthread_sigmask() probe +if test "$pthread_sigmask" != "yes" ; then + pthread_sigmask="no" +fi +cat > $TMPC < /* NULL */ +#include /* pthread_sigmask() */ +int main(void) +{ + return pthread_sigmask(0, NULL, NULL); +} +EOF +if compile_prog "" "$LIBS" "pthread_sigmask" ; then + pthread_sigmask=yes +elif compile_prog "" "$LIBS -lpthread" "pthread_sigmask" ; then + pthread_sigmask=yes + LIBS="$LIBS -lpthread" +fi +print_config "pthread_sigmask()" "$pthread_sigmask" + ########################################## # solaris aio probe if test "$solaris_aio" != "yes" ; then @@ -2534,6 +2555,9 @@ fi if test "$pthread_condattr_setclock" = "yes" ; then output_sym "CONFIG_PTHREAD_CONDATTR_SETCLOCK" fi +if test "$pthread_sigmask" = "yes" ; then + output_sym "CONFIG_PTHREAD_SIGMASK" +fi if test "$have_asprintf" = "yes" ; then output_sym "CONFIG_HAVE_ASPRINTF" fi diff --git a/helper_thread.c b/helper_thread.c index 28f6cca3..ad2e83b4 100644 --- a/helper_thread.c +++ b/helper_thread.c @@ -1,3 +1,4 @@ +#include #ifdef CONFIG_VALGRIND_DEV #include #else @@ -137,6 +138,18 @@ 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 + #ifdef CONFIG_PTHREAD_CONDATTR_SETCLOCK clock_gettime(CLOCK_MONOTONIC, &ts); #else