From owner-freebsd-current Tue Mar 11 07:43:30 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id HAA13035 for current-outgoing; Tue, 11 Mar 1997 07:43:30 -0800 (PST) Received: from ui-gate.utell.co.uk (ui-gate.utell.co.uk [194.200.4.253]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id HAA12997 for ; Tue, 11 Mar 1997 07:43:22 -0800 (PST) Received: from shift.lan.awfulhak.org (shift.utell.net [97.3.0.21]) by ui-gate.utell.co.uk (8.7.6/8.7.3) with ESMTP id PAA27855; Tue, 11 Mar 1997 15:43:14 GMT Received: from shift.lan.awfulhak.org (localhost [127.0.0.1]) by shift.lan.awfulhak.org (8.8.5/8.8.5) with ESMTP id PAA27686; Tue, 11 Mar 1997 15:44:35 GMT Message-Id: <199703111544.PAA27686@shift.lan.awfulhak.org> X-Mailer: exmh version 1.6.9 8/22/96 To: Bruce Evans cc: ache@nagual.ru, brian@awfulhak.demon.co.uk, brian@utell.co.uk, current@FreeBSD.org Subject: Re: ppp In-reply-to: Your message of "Tue, 11 Mar 1997 21:50:52 +1100." <199703111050.VAA09291@godzilla.zeta.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Reply-To: brian@utell.co.uk Date: Tue, 11 Mar 1997 15:44:35 +0000 From: Brian Somers Sender: owner-current@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk > 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< 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 Don't _EVER_ lose your sense of humour !