Ambiguity in definition of setjmp/longjmp makes them much less useful

Peter da Silva peter at ficc.ferranti.com
Wed Oct 10 04:13:46 AEST 1990


In article <891 at usage.csd.unsw.oz.au> cameron at spectrum.cs.unsw.oz.au (Cameron Simpson) writes:
> But think about what happens when you write
> 	sigfn(sig) { longjmp(foojmpbuf,1); }

> Since, as you say, a signal can happen anywhere then there is now a might-goto
> arc from _every_ point in the program which can conceivably be called from
> within any function which uses foojmpbuf as a jump buffer.

I think it reasonable not to guarantee longjmp behaviour from within
signals. In fact, calling longjmp from within signals is evil. The only
thing you should do within a signal routine is set a flag... anything
else is a bug waiting to happen.

Of course, you need to do this in BSD, but BSD is buggier than a dog pound.
-- 
Peter da Silva.   `-_-'
+1 713 274 5180.   'U`
peter at ferranti.com



More information about the Comp.lang.c mailing list