Skip to content

Commit c5422e5

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 to fix these hangs. Addresses: https://cygwin.com/pipermail/cygwin/2024-December/256987.html Fixes: a22a0ad ("Cygwin: signal: Do not handle signal when __SIGFLUSHFAST is sent") Reported-by: Jeremy Drake <[email protected]> Reviewed-by: Signed-off-by: Takashi Yano <[email protected]>
1 parent 9c19a59 commit c5422e5

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

winsup/cygwin/sigproc.cc

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -751,14 +751,21 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
751751
res = WriteFile (sendsig, leader, packsize, &nb, NULL);
752752
if (!res || packsize == nb)
753753
break;
754-
if (cygwait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED
755-
&& pack.si.si_signo != __SIGFLUSHFAST)
756-
_my_tls.call_signal_handler ();
754+
if (pack.si.si_signo == __SIGFLUSHFAST)
755+
Sleep (10);
756+
else /* Handle signals */
757+
do
758+
{
759+
DWORD rc = WaitForSingleObject (_my_tls.get_signal_arrived (), 10);
760+
if (rc == WAIT_OBJECT_0)
761+
{
762+
_my_tls.call_signal_handler ();
763+
continue;
764+
}
765+
}
766+
while (false);
757767
res = 0;
758768
}
759-
/* Re-assert signal_arrived which has been cleared in cygwait(). */
760-
if (_my_tls.sig)
761-
_my_tls.set_signal_arrived ();
762769

763770
if (!res)
764771
{
@@ -789,16 +796,20 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
789796
if (wait_for_completion)
790797
{
791798
sigproc_printf ("Waiting for pack.wakeup %p", pack.wakeup);
792-
do
793-
{
794-
rc = cygwait (pack.wakeup, WSSC, cw_sig_eintr);
795-
if (rc == WAIT_SIGNALED && pack.si.si_signo != __SIGFLUSHFAST)
796-
_my_tls.call_signal_handler ();
797-
}
798-
while (rc != WAIT_OBJECT_0 && rc != WAIT_TIMEOUT);
799-
/* Re-assert signal_arrived which has been cleared in cygwait(). */
800-
if (_my_tls.sig)
801-
_my_tls.set_signal_arrived ();
799+
if (pack.si.si_signo == __SIGFLUSHFAST)
800+
rc = WaitForSingleObject (pack.wakeup, WSSC);
801+
else /* Handle signals */
802+
do
803+
{
804+
HANDLE w[2] = {pack.wakeup, _my_tls.get_signal_arrived ()};
805+
rc = WaitForMultipleObjects (2, w, FALSE, WSSC);
806+
if (rc == WAIT_OBJECT_0 + 1) /* signal arrived */
807+
{
808+
_my_tls.call_signal_handler ();
809+
continue;
810+
}
811+
}
812+
while (false);
802813
ForceCloseHandle (pack.wakeup);
803814
}
804815
else

0 commit comments

Comments
 (0)