[PATCH] Cygwin: sigproc: Do not send signal to myself if exiting.

Takashi Yano takashi.yano@nifty.ne.jp
Fri Nov 19 18:14:58 GMT 2021


On Fri, 19 Nov 2021 18:22:40 +0100
Corinna Vinschen wrote:
> On Nov 20 02:14, Takashi Yano wrote:
> > On Fri, 19 Nov 2021 16:53:57 +0100
> > Corinna Vinschen wrote:
> > > On Nov 19 16:51, Corinna Vinschen wrote:
> > > > Isn't that already handled in wait_sig?  What's the difference here?
> > > 
> > > ...and where exactly is it waiting 60 secs?
> > 
> > If sending signal to myself with exit_state > ES_EXIT_STARGING,
> > wait_for_completion in sig_send() is set to true. Therefore,
> > sig_send() waits for pack.wakeup event for WSSC (60000 msec) here:
> > 
> >   /* No need to wait for signal completion unless this was a signal to
> >      this process.
> > 
> >      If it was a signal to this process, wait for a dispatched signal.
> >      Otherwise just wait for the wait_sig to signal that it has finished
> >      processing the signal.  */
> >   if (wait_for_completion)
> >     {
> >       sigproc_printf ("Waiting for pack.wakeup %p", pack.wakeup);
> >       rc = WaitForSingleObject (pack.wakeup, WSSC);
> >       ForceCloseHandle (pack.wakeup);
> >     }
> > 
> > However, thread wait_sig ignores the signal here:
> >       /* Don't process signals when we start exiting */
> >       if (exit_state > ES_EXIT_STARTING && pack.si.si_signo > 0)
> >         continue;
> > and does not call SetEvent (pack.wakeup).
> > 
> > As a result, sig_send() hangs for 60 secs.
> > 
> > With this patch, sig_send() does not send signal which will
> > be ignored in wait_sig().
> 
> Ah, ok, that makes sense.  Thanks for the explanation.  Please push.

Ah, this patch may cause race issue regarding exit_state.
I will submit another patch which overrides this patch.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>


More information about the Cygwin-patches mailing list