diff mbox series

[hurd,commited] htl: make pthread_sigstate read/write set/oset outside sigstate section

Message ID 20210925230548.2505397-1-samuel.thibault@ens-lyon.org
State Committed, archived
Headers show
Series [hurd,commited] htl: make pthread_sigstate read/write set/oset outside sigstate section | expand

Checks

Context Check Description
dj/TryBot-apply_patch fail Patch failed to apply to master at the time it was sent
dj/TryBot-32bit fail Patch series failed to apply

Commit Message

Samuel Thibault Sept. 25, 2021, 11:05 p.m. UTC
so that if a segfault occurs, the handler can run fine.
---
 sysdeps/mach/hurd/htl/pt-sigstate.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/sysdeps/mach/hurd/htl/pt-sigstate.c b/sysdeps/mach/hurd/htl/pt-sigstate.c
index 85abf81dec..7bc9fb7b77 100644
--- a/sysdeps/mach/hurd/htl/pt-sigstate.c
+++ b/sysdeps/mach/hurd/htl/pt-sigstate.c
@@ -30,30 +30,33 @@  __pthread_sigstate (struct __pthread *thread, int how,
 {
   error_t err = 0;
   struct hurd_sigstate *ss;
+  sigset_t old, new;
   sigset_t pending;
 
+  if (set != NULL)
+    new = *set;
+
   ss = _hurd_thread_sigstate (thread->kernel_thread);
   assert (ss);
 
   _hurd_sigstate_lock (ss);
 
-  if (oset != NULL)
-    *oset = ss->blocked;
+  old = ss->blocked;
 
   if (set != NULL)
     {
       switch (how)
 	{
 	case SIG_BLOCK:
-	  ss->blocked |= *set;
+	  ss->blocked |= new;
 	  break;
 
 	case SIG_SETMASK:
-	  ss->blocked = *set;
+	  ss->blocked = new;
 	  break;
 
 	case SIG_UNBLOCK:
-	  ss->blocked &= ~*set;
+	  ss->blocked &= ~new;
 	  break;
 
 	default:
@@ -69,6 +72,9 @@  __pthread_sigstate (struct __pthread *thread, int how,
   pending = _hurd_sigstate_pending (ss) & ~ss->blocked;
   _hurd_sigstate_unlock (ss);
 
+  if (!err && oset != NULL)
+    *oset = old;
+
   if (!err && pending)
     /* Send a message to the signal thread so it
        will wake up and check for pending signals.  */