[newlib-cygwin/cygwin-3_5-branch] Cygwin: signal: Handle queued signal without explicit __SIGFLUSH

Corinna Vinschen corinna@sourceware.org
Fri Dec 6 10:47:02 GMT 2024


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

commit 09be373e4594345e65ef966122a85fc35a35cef3
Author:     Takashi Yano <takashi.yano@nifty.ne.jp>
AuthorDate: Mon Nov 25 20:19:06 2024 +0900
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Fri Dec 6 11:30:13 2024 +0100

    Cygwin: signal: Handle queued signal without explicit __SIGFLUSH
    
    With the previous code, the queued signal is tried to resend only when
    a new signal arrives or pending_signals::pending() is called.
    With this patch, if the signal is queued and the retry flag is not set
    and the new signal is not received yet, the sig thread tries to handle
    the queued signal again. Without this patch, the chance to handle the
    queue would be delayed.
    
    Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html
    Fixes: 5e31c80e4e8d ("(pending_signals::pending): Force an additional loop through wait_sig by setting retry whenever this function is called.")
    Reported-by: Christian Franke <Christian.Franke@t-online.de>
    Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
    (cherry picked from commit e10f822a2b39bade20858ba3c704a8bb7d965cb4)

Diff:
---
 winsup/cygwin/sigproc.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 2e813b3a7e77..ecf79bc71283 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -1321,6 +1321,9 @@ wait_sig (VOID *)
       sigpacket pack = {};
       if (sigq.retry)
 	pack.si.si_signo = __SIGFLUSH;
+      else if (sigq.start.next
+	       && PeekNamedPipe (my_readsig, NULL, 0, NULL, &nb, NULL) && !nb)
+	pack.si.si_signo = __SIGFLUSH;
       else if (!ReadFile (my_readsig, &pack, sizeof (pack), &nb, NULL))
 	Sleep (INFINITE);	/* Assume were exiting.  Never exit this thread */
       else if (nb != sizeof (pack) || !pack.si.si_signo)


More information about the Cygwin-cvs mailing list