Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Jun 2004 15:31:11 +0200 (CEST)
From:      Oliver Fromme <olli@lurza.secnetix.de>
To:        freebsd-amd64@FreeBSD.ORG
Subject:   Re: signal handler priority issue
Message-ID:  <200406111331.i5BDVBQw097559@lurza.secnetix.de>
In-Reply-To: <1086946114.76446.16.camel@server.mcneil.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Sean McNeil <sean@mcneil.com> wrote:
 > The program below has an optimization bug in that done isn't declare
 > volatile.  With that fixed, it works just fine.

Sorry for jumping in here ...  Just for completeness:
The C standard also requires that variables must be of type
sig_atomic_t if they're used from within signal handlers.

For FreeBSD it doesn't matter, because sig_atomic_t is de-
fined as int, but nonetheless that special type should be
used for the sake of conformance and portability (and it
also serves for documentation).

So, the correct declaration would be:
static volatile sig_atomic_t   done = 0;

Regards
   Oliver

-- 
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

(On the statement print "42 monkeys" + "1 snake":)  By the way,
both perl and Python get this wrong.  Perl gives 43 and Python
gives "42 monkeys1 snake", when the answer is clearly "41 monkeys
and 1 fat snake".        -- Jim Fulton



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406111331.i5BDVBQw097559>