With previous code, queued signal is tried to resend only when a
new signal is arrived or pending_signals::pending() is called.
With this patch, if signal is queued and retry flag is not set
and new signal is not received yet, 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.fra...@t-online.de>
Reviewed-by:
Signed-off-by: Takashi Yano <takashi.y...@nifty.ne.jp>
---
 winsup/cygwin/sigproc.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 66ffef8f1..34e459070 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -1329,6 +1329,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)
-- 
2.45.1

Reply via email to