Skip to content

Commit b6a94e2

Browse files
tyan0jeremyd2019
authored andcommitted
Cygwin: signal: Do not handle signal when __SIGFLUSHFAST is sent
The commit a22a0ad was not exactly the correct thing. Even with the patch, some hangs still happen. This patch overrides the previous commit togerther with the patch making cygwait() reentrant to fix these hangs. Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256954.html Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256987.html Fixes: d243e51 ("Cygwin: signal: Fix deadlock between main thread and sig thread") Fixes: a22a0ad ("Cygwin: signal: Do not handle signal when __SIGFLUSHFAST is sent") Reported-by: Daisuke Fujimura <[email protected]> Reported-by: Jeremy Drake <[email protected]> Reviewed-by: Signed-off-by: Takashi Yano <[email protected]>
1 parent 96aae8a commit b6a94e2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

winsup/cygwin/sigproc.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,12 @@ 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+
if (pack.si.si_signo == __SIGFLUSHFAST)
747+
cw_mask = 0;
748+
else
749+
cw_mask = cw_sig_restart;
750+
745751
DWORD nb;
746752
BOOL res;
747753
/* Try multiple times to send if packsize != nb since that probably
@@ -751,8 +757,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
751757
res = WriteFile (sendsig, leader, packsize, &nb, NULL);
752758
if (!res || packsize == nb)
753759
break;
754-
if (cygwait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED)
755-
_my_tls.call_signal_handler ();
760+
cygwait (NULL, 10, cw_mask);
756761
res = 0;
757762
}
758763

@@ -785,7 +790,7 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
785790
if (wait_for_completion)
786791
{
787792
sigproc_printf ("Waiting for pack.wakeup %p", pack.wakeup);
788-
rc = cygwait (pack.wakeup, WSSC);
793+
rc = cygwait (pack.wakeup, WSSC, cw_mask);
789794
ForceCloseHandle (pack.wakeup);
790795
}
791796
else
@@ -806,9 +811,6 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
806811
rc = -1;
807812
}
808813

809-
if (wait_for_completion && si.si_signo != __SIGFLUSHFAST)
810-
_my_tls.call_signal_handler ();
811-
812814
out:
813815
if (communing && rc)
814816
{

0 commit comments

Comments
 (0)