summary refs log tree commit diff
path: root/nptl/pthread_create.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2020-06-02 10:34:55 +0200
committerFlorian Weimer <fweimer@redhat.com>2020-06-02 11:59:18 +0200
commitec41af45a6d25f70f9c7ea15cb831a2b2fea3855 (patch)
tree485ea3129bf12117c40b6784807869564fc8af1e /nptl/pthread_create.c
parent7538d461134bf306e31b40e4032f0c225bb40d51 (diff)
downloadglibc-ec41af45a6d25f70f9c7ea15cb831a2b2fea3855.tar.gz
glibc-ec41af45a6d25f70f9c7ea15cb831a2b2fea3855.tar.xz
glibc-ec41af45a6d25f70f9c7ea15cb831a2b2fea3855.zip
nptl: Add pthread_attr_setsigmask_np, pthread_attr_getsigmask_np
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'nptl/pthread_create.c')
-rw-r--r--nptl/pthread_create.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index f6418eb5ed..35a9927cf2 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)))