signal handler priority issue
Oliver Fromme
olli at lurza.secnetix.de
Fri Jun 11 13:31:47 GMT 2004
Sean McNeil <sean at 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
More information about the freebsd-amd64
mailing list