From a5da9128ebbe2df954b43c0127f00ef0d4d15ed4 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 3 Apr 2019 18:14:30 +0200 Subject: [PATCH] Cygwin: signals: restore sigmask from context given to signal handler In case SA_SIGINFO flag is given, the signal handler may change the context and the application is supposed to pick up from the changed context. So far we don't do that, so the context given to the signal handler is basically read-only, unless the signal handler calls setcontext or swapcontext. For a start, restore the thread's signal mask from the uc_sigmask value of the context given to the signal handler. If that's feasible for Cygwin, we restore the entire context from the context changed by the signal handler in a followup patch. Signed-off-by: Corinna Vinschen --- winsup/cygwin/exceptions.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index da4348fdb..a9b378133 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1818,7 +1818,8 @@ _cygtls::call_signal_handler () incyg = true; - set_signal_mask (_my_tls.sigmask, this_oldmask); + set_signal_mask (_my_tls.sigmask, (this_sa_flags & SA_SIGINFO) + ? context.uc_sigmask : this_oldmask); if (this_errno >= 0) set_errno (this_errno); }