https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2544e753963e9c15a9e3fe35188d8dea7b39d748
commit 2544e753963e9c15a9e3fe35188d8dea7b39d748 Author: Takashi Yano <[email protected]> Date: Fri Nov 29 17:13:32 2024 +0900 Cygwin: signal: Fix a short period of deadlock The main thread waits for the sig thread to read the signal pipe by calling Sleep(10) if writing to the signal pipe has failed. However, if the signal thread waiting for another signal being handled in the main thread, the sig thread does not read the signal pipe. To avoid such a situation, this patch replaces Sleep(10) to cygwait(). Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html Fixes: 6f05b327678f ("(sig_send): Retry WriteFiles which fail when there is no error but packbytes have not been sent.") Reported-by: Christian Franke <[email protected]> Reviewed-by: Corinna Vinschen <[email protected]> Signed-off-by: Takashi Yano <[email protected]> Diff: --- winsup/cygwin/sigproc.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index 4d50a5865..decc7def0 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -727,7 +727,8 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls) res = WriteFile (sendsig, leader, packsize, &nb, NULL); if (!res || packsize == nb) break; - Sleep (10); + if (cygwait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED) + _my_tls.call_signal_handler (); res = 0; }
