[newlib-cygwin] Cygwin: signal: Fix a problem that process hangs on exit

Takashi Yano tyan0@sourceware.org
Mon Mar 3 19:27:33 GMT 2025


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

commit 3c1308ed890eac4333d0a16f5795203cee4f38b2
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Fri Feb 28 16:56:30 2025 +0900

    Cygwin: signal: Fix a problem that process hangs on exit
    
    The process that receives many SIGSTOP/SIGCONT signals sometimes hangs
    on exit in sig_dispatch_pending(). This patch skips processing signals
    in call_signal_handler() when exit_state > ES_EXIT_STARTING to avoid
    that situation.
    
    Addresses: https://cygwin.com/pipermail/cygwin/2025-February/257473.html
    Fixes: d243e51ef1d3 ("Cygwin: signal: Fix deadlock between main thread and sig thread")
    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>

Diff:
---
 winsup/cygwin/exceptions.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index 45c71cbdf..759f89dca 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -1675,7 +1675,7 @@ _cygtls::call_signal_handler ()
   while (1)
     {
       lock ();
-      if (!current_sig)
+      if (!current_sig || exit_state > ES_EXIT_STARTING)
 	{
 	  unlock ();
 	  break;


More information about the Cygwin-cvs mailing list