Another race in signal handling

Marc Lehmann schmorp at schmorp.de
Mon Jan 21 05:57:36 CET 2008


On Wed, Jan 16, 2008 at 09:15:50AM -0500, Chris Shoemaker <c.shoemaker at cox.net> wrote:
> The condition is true, and gotsig becomes 1.  The signal handler returns.
> 
> However, as soon as the sighandler returns, the full signal mask is
> removed, so a new signal may be received at any time.  If a signal is
> received before sigcb() clears gotsig, the sighandler will not record
> it, because (!gotsig) will still be false.

Thats wrong, just look at the code you quote:

>    signals [signum - 1].gotsig = 1;

Here the signal gets recorded, which is independent of the global gotsig
variable, so what you write cannot be true, as the signal will be recorded
regardless of the value of gotsig.

indepdnent means the signal occurance will be recorded regardless of the
value of "gotsig".

gotsig simply controls wether the event loop should be woken up, signals
cannot go lost even when gotsig is forced to be 1 all the time (but it can
delay signal handling indefinitely).

> But, I don't understand the motive for the flag in the first place, so

Are you sure you didn't tinker with the code in other places and this is a
pristine copy of libev you are looking at?

In any case, it would be better not to make (wrong) analysis of the
perceived problems you see, but instead describe your problem, maybe
deliver a testcase and maybe make a (possibly wrong) analysis of the
problem (which is often helpful).

Without the actual problem report, such analyses are, however, useless.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg at goof.com
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list