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

commit 48e7e33b9f63e72196e2286c0150232312f55880
Author: Takashi Yano <[email protected]>
Date:   Tue Mar 10 10:43:18 2026 +0900

    Cygwin: signal: Wait for `sendsig` for a sufficient amount of time
    
    The current code waits for `sendsig` by `for` loop in sigproc.cc,
    however, the wait time might be insufficient for recent CPU.
    The current code is as follows.
    
       for (int i = 0; !p->sendsig && i < 10000; i++)
         yield ();
    
    Due to this problem, in tcsh, the following command occasionally
    cannot be terminated by Ctrl-C. This is because, SIGCONT does not
    wake-up `sleep` process correctly.
    
      $ cat | sleep 100 &
      $ fg
      $ (type Ctrl-C)
    
    With this patch, the wait time for `sendsig` is guaranteed to be
    up to 100ms instead of looping for 10000 times.
    
    Fixes: d584454c8231 ("* sigproc.cc (sig_send): Wait for dwProcessId to be 
non-zero as well as sendsig.")
    Signed-off-by: Takashi Yano <[email protected]>
    Reviewed-by: Corinna Vinschen <[email protected]>
    (cherry picked from commit f65c9f0c44444689b732a61ea37589293f70ae64)

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 30779cf8e..0fd7ed3ba 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -646,7 +646,8 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
     {
       HANDLE dupsig;
       DWORD dwProcessId;
-      for (int i = 0; !p->sendsig && i < 10000; i++)
+      DWORD t0 = GetTickCount ();
+      while (GetTickCount () - t0 < 100 && !p->sendsig)
        yield ();
       if (p->sendsig)
        {

Reply via email to