Skip to content

Commit adb9c01

Browse files
tyan0jeremyd2019
authored andcommitted
Cygwin: signal: Do not handle signal when __SIGFLUSHFAST is sent
The commit a22a0ad was not entirely correct. Even with the patch, some hangs still occur. This patch overrides the previous commit along with the patch that makes cygwait() reentrant, to fix these hangs. Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256954.html Fixes: d243e51 ("Cygwin: signal: Fix deadlock between main thread and sig thread") Reported-by: Daisuke Fujimura <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]> (cherry picked from commit 83afe3e)
1 parent 9f9cfe9 commit adb9c01

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

winsup/cygwin/sigproc.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,9 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
742742
memcpy (p, si._si_commune._si_str, n); p += n;
743743
}
744744

745+
unsigned cw_mask;
746+
cw_mask = pack.si.si_signo == __SIGFLUSHFAST ? 0 : cw_sig_restart;
747+
745748
DWORD nb;
746749
BOOL res;
747750
/* Try multiple times to send if packsize != nb since that probably
@@ -751,8 +754,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
751754
res = WriteFile (sendsig, leader, packsize, &nb, NULL);
752755
if (!res || packsize == nb)
753756
break;
754-
if (cygwait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED)
755-
_my_tls.call_signal_handler ();
757+
cygwait (NULL, 10, cw_mask);
756758
res = 0;
757759
}
758760

@@ -785,7 +787,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
785787
if (wait_for_completion)
786788
{
787789
sigproc_printf ("Waiting for pack.wakeup %p", pack.wakeup);
788-
rc = cygwait (pack.wakeup, WSSC);
790+
rc = cygwait (pack.wakeup, WSSC, cw_mask);
789791
ForceCloseHandle (pack.wakeup);
790792
}
791793
else
@@ -806,9 +808,6 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
806808
rc = -1;
807809
}
808810

809-
if (wait_for_completion && si.si_signo != __SIGFLUSHFAST)
810-
_my_tls.call_signal_handler ();
811-
812811
out:
813812
if (communing && rc)
814813
{

0 commit comments

Comments
 (0)