public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: follow context if changed inside SA_SIGINFO signal handler
@ 2019-04-05  9:25 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2019-04-05  9:25 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=181ca73e493ee134aec1431f398423ed619627b2

commit 181ca73e493ee134aec1431f398423ed619627b2
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Fri Apr 5 11:25:19 2019 +0200

    Cygwin: follow context if changed inside SA_SIGINFO signal handler
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/exceptions.cc | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 0aaeee5..e5e7703 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1645,7 +1645,7 @@ _cygtls::call_signal_handler ()
       siginfo_t thissi = infodata;
       void (*thisfunc) (int, siginfo_t *, void *) = func;
 
-      ucontext_t *thiscontext = NULL;
+      ucontext_t *thiscontext = NULL, context_copy;
 
       /* Only make a context for SA_SIGINFO handlers */
       if (this_sa_flags & SA_SIGINFO)
@@ -1701,6 +1701,7 @@ _cygtls::call_signal_handler ()
 				    ? (uintptr_t) thissi.si_addr : 0;
 
 	  thiscontext = &context;
+	  context_copy = context;
 	}
 
       int this_errno = saved_errno;
@@ -1822,6 +1823,14 @@ _cygtls::call_signal_handler ()
 					? context.uc_sigmask : this_oldmask);
       if (this_errno >= 0)
 	set_errno (this_errno);
+      if (this_sa_flags & SA_SIGINFO)
+	{
+	  /* If more than just the sigmask in the context has been changed by
+	     the signal handler, call setcontext. */
+	  context_copy.uc_sigmask = context.uc_sigmask;
+	  if (memcmp (&context, &context_copy, sizeof context) != 0)
+	    setcontext (&context);
+	}
     }
 
   /* FIXME: Since 2011 this return statement always returned 1 (meaning


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-05  9:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-05  9:25 [newlib-cygwin] Cygwin: follow context if changed inside SA_SIGINFO signal handler Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).