Date: Tue, 11 Mar 1997 15:44:35 +0000 From: Brian Somers <brian@shift.lan.awfulhak.org> To: Bruce Evans <bde@zeta.org.au> Cc: ache@nagual.ru, brian@awfulhak.demon.co.uk, brian@utell.co.uk, current@FreeBSD.org Subject: Re: ppp Message-ID: <199703111544.PAA27686@shift.lan.awfulhak.org> In-Reply-To: Your message of "Tue, 11 Mar 1997 21:50:52 %2B1100." <199703111050.VAA09291@godzilla.zeta.org.au>
next in thread | previous in thread | raw e-mail | index | archive | help
> Generally you don't care and can't tell exactly how many signals occurred
> (the system doesn't count them).  One exception might be if SIGALRM is
> pended and there is too large a latrency before unpending.  Then counting
> could be used to tell how many SIGALRMs were mishandled :-).
> 
> The main problems here are:
> 1. the code is non-portable.  sigset_t might be larger than int, and not
>    using sigset_t makes it hard to use sigprocmask().
> 2. `caused &= ~(1<<sig);' might not be atomic.  All signals should be
>    blocked when `caused' is changed.
> 3. Some signals should probably be blocked when the handler is called.
>    See Andrey's old mail.
> 4. Perhaps there should a loop to handle signals that arrive after `had'
>    is initialized.  This depends on how long you can afford to wait
>    before the next call to handle signals.  Some locking may be required.
> 
[.....]
> Bruce
&= ~ isn't guaranteed atomic ?  Yeuch.  I'd tend to go with Andrey's
suggestion that I use an int array rather than a bit array.  I assume
that ++ and -- are guaranteed to be atomic (if they're not, I'm in *lots*
of trouble).
This should solve the above.  The process loop will look something like:
extern int ncaused;  /* The cumulative number of signals caused */
int sig;
while (ncaused) {
    for (sig = 0; sig < __MAXSIG; sig++)
        if (caused[sig]) {
            ncaused--;
            caused[sig]--;
            (*handler[sig])(sig+1);
        }
}
The actual signal trap would of course increment caused[n] and ncaused.
-- 
Brian <brian@awfulhak.demon.co.uk> <brian@freebsd.org>
      <http://www.awfulhak.demon.co.uk>
Don't _EVER_ lose your sense of humour !
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703111544.PAA27686>
