Skip to content

Commit 746c3d7

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 6754077 commit 746c3d7

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

winsup/cygwin/sigproc.cc

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,19 @@ 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-
_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);
756767
res = 0;
757768
}
758769

@@ -785,7 +796,20 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
785796
if (wait_for_completion)
786797
{
787798
sigproc_printf ("Waiting for pack.wakeup %p", pack.wakeup);
788-
rc = cygwait (pack.wakeup, WSSC);
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);
789813
ForceCloseHandle (pack.wakeup);
790814
}
791815
else
@@ -806,9 +830,6 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
806830
rc = -1;
807831
}
808832

809-
if (wait_for_completion && si.si_signo != __SIGFLUSHFAST)
810-
_my_tls.call_signal_handler ();
811-
812833
out:
813834
if (communing && rc)
814835
{

0 commit comments

Comments
 (0)