about summary refs log tree commit diff
path: root/nptl/sysdeps/unix/sysv
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-04-20 02:52:14 +0000
committerUlrich Drepper <drepper@redhat.com>2004-04-20 02:52:14 +0000
commitfa0e226b387fce0009c66c68ada459e28be0b9c8 (patch)
tree334ffd0f0d795e5b2ed2ba6ffda5f788625c7d91 /nptl/sysdeps/unix/sysv
parent2282308567172d8a4be99f5e02a5fe8f52bbc68a (diff)
downloadglibc-fa0e226b387fce0009c66c68ada459e28be0b9c8.tar.gz
glibc-fa0e226b387fce0009c66c68ada459e28be0b9c8.tar.xz
glibc-fa0e226b387fce0009c66c68ada459e28be0b9c8.zip
Make sure helper thread has all signals blocked.
Diffstat (limited to 'nptl/sysdeps/unix/sysv')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/timer_routines.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/timer_routines.c b/nptl/sysdeps/unix/sysv/linux/timer_routines.c
index f0a68e8f4d..ae5f1f7b54 100644
--- a/nptl/sysdeps/unix/sysv/linux/timer_routines.c
+++ b/nptl/sysdeps/unix/sysv/linux/timer_routines.c
@@ -32,6 +32,14 @@
 static void *
 timer_sigev_thread (void *arg)
 {
+  /* The parent thread has all signals blocked.  This is a bit
+     surprising for user code, although valid.  We unblock all
+     signals.  */
+  sigset_t ss;
+  sigemptyset (&ss);
+  INTERNAL_SYSCALL_DECL (err);
+  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, NULL, _NSIG / 8);
+
   struct timer *tk = (struct timer *) arg;
 
   /* Call the user-provided function.  */
@@ -45,16 +53,10 @@ timer_sigev_thread (void *arg)
 static void *
 timer_helper_thread (void *arg)
 {
-  /* Block all signals.  We will only wait for the signal the kernel
-     will send.  */
+  /* Wait for the SIGTIMER signal and none else.  */
   sigset_t ss;
   sigemptyset (&ss);
   sigaddset (&ss, SIGTIMER);
-  /* SIGTIMER is the same signal as SIGCANCEL and it is therefore
-     unblocked so far.  Block it for this thread, we handle
-     cancellation explicitly.  */
-  INTERNAL_SYSCALL_DECL (err);
-  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &ss, NULL, _NSIG / 8);
 
   /* Endless loop of waiting for signals.  The loop is only ended when
      the thread is canceled.  */
@@ -119,6 +121,14 @@ __start_helper_thread (void)
   (void) pthread_attr_init (&attr);
   (void) pthread_attr_setstacksize (&attr, PTHREAD_STACK_MIN);
 
+  /* Block all signals in the helper thread.  To do this thoroughly we
+     temporarily have to block all signals here.  */
+  sigset_t ss;
+  sigset_t oss;
+  sigfillset (&ss);
+  INTERNAL_SYSCALL_DECL (err);
+  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &ss, &oss, _NSIG / 8);
+
   /* Create the helper thread for this timer.  */
   pthread_t th;
   int res = pthread_create (&th, &attr, timer_helper_thread, NULL);
@@ -126,6 +136,10 @@ __start_helper_thread (void)
     /* We managed to start the helper thread.  */
     __helper_tid = ((struct pthread *) th)->tid;
 
+  /* Restore the signal mask.  */
+  INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, &oss, NULL,
+		    _NSIG / 8);
+
   /* No need for the attribute anymore.  */
   (void) pthread_attr_destroy (&attr);