[PATCH 9/9] Cygwin: signal: Fix a short period of deadlock
Corinna Vinschen
corinna-cygwin@cygwin.com
Mon Dec 2 15:21:11 GMT 2024
On Nov 29 20:59, Takashi Yano wrote:
> The main thread waits for the sig thread to read the signal pipe by
> calling Sleep(10) if writing to the signal pipe has failed. However,
> if the signal thread waiting for another signal being handled in the
> main thread, the sig thread does not read the signal pipe. To avoid
> such a situation, this patch replaces Sleep(10) to cygwait().
>
> Addresses: https://cygwin.com/pipermail/cygwin/2024-November/256744.html
> Fixes: 6f05b327678f ("(sig_send): Retry WriteFiles which fail when there is no error but packbytes have not been sent.")
> 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 | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
> index 8c788bd20..4c557f048 100644
> --- a/winsup/cygwin/sigproc.cc
> +++ b/winsup/cygwin/sigproc.cc
> @@ -741,7 +741,8 @@ sig_send (_pinfo *p, siginfo_t& si, _cygtls *tls)
> res = WriteFile (sendsig, leader, packsize, &nb, NULL);
> if (!res || packsize == nb)
> break;
> - Sleep (10);
> + if (cygwait (NULL, 10, cw_sig_eintr) == WAIT_SIGNALED)
> + _my_tls.call_signal_handler ();
> res = 0;
> }
>
> --
> 2.45.1
LGTM.
Thanks,
Corinna
More information about the Cygwin-patches
mailing list