https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8fa1c02625c9c962690291fc6dcd6685ed110544

commit 8fa1c02625c9c962690291fc6dcd6685ed110544
Author:     Takashi Yano <[email protected]>
AuthorDate: Fri Nov 29 17:13:32 2024 +0900
Commit:     Corinna Vinschen <[email protected]>
CommitDate: Fri Dec 6 11:42:32 2024 +0100

    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]>
    (cherry picked from commit 2544e753963e9c15a9e3fe35188d8dea7b39d748)

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 618cc45565c6..601147ff6ce6 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;
     }

Reply via email to