longjmp() from nested signal handlers

Neal Weidenhofer nw at amdahl.uts.amdahl.com
Wed Apr 6 07:11:54 AEST 1988


In article <4548 at june.cs.washington.edu>, pardo at june.cs.washington.edu (David Keppel) writes:
> I also don't understand why jumping out of a nested signal handler
> is different from jumping out of a non-nested handler.
> 
>     pardo at cs.washington.edu	..!ucbvax!uw-beaver!uw-june!pardo

It isn't.  Using longjump from a signal handler ALWAYS results in
undefined behavior.

My favorite example is to consider the case of the signal being
raised while the program is in the middle of malloc(3) (for UN*X
types--something equivalent if you're using VMS or some other
OS).  There is NO WAY that your program is going to continue to
run correctly after control has been forcibly removed from some
routine while its internal tables are in an inconsistent state.

This is why dpANS limits signal handlers to setting a flag and
returning.  Most compilers and/or OS's are going to have to do
some work even to get this right.

The opinions expressed above are mine (but I'm willing to share.)

			Regards,
				Neal Weidenhofer
Nothin' ain't woth nothin'      ...{hplabs|ihnp4|ames|decwrl}!amdahl!nw
   But it's free.               Amdahl Corporation
				1250 E. Arques Ave. (M/S 316)
				P. O. Box 3470
				Sunnyvale, CA 94088-3470
				(408)737-5007



More information about the Comp.lang.c mailing list