Currently, _cygtls::sigmask is set in call_signal_handler(), but this
is too late to effectively prevent a masked signal from being armed. 
With this patch, sigmask is set in _cygtls::interrupt_setup() instead.

Fixes: 0d675c5d7f24 ("* exceptions.cc (interrupt_setup): Don't set signal mask 
here or races occur with main thread.  Set it in sigdelayed instead.")
Reviewed-by:
Signed-off-by: Takashi Yano <[email protected]>
---
 winsup/cygwin/exceptions.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index bcc7fe6f8..688297d76 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -980,7 +980,8 @@ void
 _cygtls::interrupt_setup (siginfo_t& si, void *handler, struct sigaction& siga)
 {
   push ((__tlsstack_t) sigdelayed);
-  deltamask = siga.sa_mask & ~SIG_NONMASKABLE;
+  oldmask = sigmask;
+  sigmask = (sigmask | siga.sa_mask) & ~SIG_NONMASKABLE;
   sa_flags = siga.sa_flags;
   func = (void (*) (int, siginfo_t *, void *)) handler;
   if (siga.sa_flags & SA_RESETHAND)
@@ -1721,7 +1722,7 @@ _cygtls::call_signal_handler ()
       debug_only_printf ("dealing with signal %d", current_sig);
       this_sa_flags = sa_flags;
 
-      sigset_t this_oldmask = set_process_mask_delta ();
+      sigset_t this_oldmask = _my_tls.oldmask;
 
       if (infodata.si_code == SI_TIMER)
        {
-- 
2.45.1

Reply via email to