[PATCH] Cygwin: signal: Increase chance of handling signal in main thread
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue Dec 3 14:31:32 GMT 2024
On Dec 3 23:01, Takashi Yano wrote:
> If process() failed and the signal remains in the queue, the most
> possible reason is that the target thread already armed by another
> signal and do not handle it yet. With this patch, to increase the
> chance of handling it in the other threads, call yield() before
> retrying process().
>
> Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html
> Fixes: e10f822a2b39 ("Cygwin: signal: Handle queued signal without explicit __SIGFLUSH")
> Reported-by: Christian Franke <Christian.Franke@t-online.de>
> Reviewed-by:
> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
> ---
> winsup/cygwin/sigproc.cc | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
> index 4c557f048..7e02e61f7 100644
> --- a/winsup/cygwin/sigproc.cc
> +++ b/winsup/cygwin/sigproc.cc
> @@ -1342,7 +1342,10 @@ wait_sig (VOID *)
> pack.si.si_signo = __SIGFLUSH;
> else if (sigq.start.next
> && PeekNamedPipe (my_readsig, NULL, 0, NULL, &nb, NULL) && !nb)
> - pack.si.si_signo = __SIGFLUSH;
> + {
> + yield ();
> + 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
LGTM.
Thanks,
Corinna
More information about the Cygwin-patches
mailing list