From ec41af45a6d25f70f9c7ea15cb831a2b2fea3855 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Tue, 2 Jun 2020 10:34:55 +0200 Subject: nptl: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_np Reviewed-by: Carlos O'Donell Tested-by: Carlos O'Donell --- nptl/pthread_create.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'nptl/pthread_create.c') diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c index f6418eb..35a9927 100644 --- a/nptl/pthread_create.c +++ b/nptl/pthread_create.c @@ -745,14 +745,23 @@ __pthread_create_2_1 (pthread_t *newthread, const pthread_attr_t *attr, sigset_t original_sigmask; __libc_signal_block_all (&original_sigmask); - /* Conceptually, the new thread needs to inherit the signal mask of - this thread. Therefore, it needs to restore the saved signal - mask of this thread, so save it in the startup information. */ - pd->sigmask = original_sigmask; - - /* Reset the cancellation signal mask in case this thread is running - cancellation. */ - __sigdelset (&pd->sigmask, SIGCANCEL); + if (iattr->extension != NULL && iattr->extension->sigmask_set) + /* Use the signal mask in the attribute. The internal signals + have already been filtered by the public + pthread_attr_setsigmask_np interface. */ + pd->sigmask = iattr->extension->sigmask; + else + { + /* Conceptually, the new thread needs to inherit the signal mask + of this thread. Therefore, it needs to restore the saved + signal mask of this thread, so save it in the startup + information. */ + pd->sigmask = original_sigmask; + + /* Reset the cancellation signal mask in case this thread is + running cancellation. */ + __sigdelset (&pd->sigmask, SIGCANCEL); + } /* Start the thread. */ if (__glibc_unlikely (report_thread_creation (pd))) -- cgit v1.1