longjmp() from nested signal handlers

Bob Larson blarson at skat.usc.edu
Wed Apr 6 17:01:16 AEST 1988


In article <26739 at amdahl.uts.amdahl.com> nw at amdahl.uts.amdahl.com (Neal Weidenhofer) writes:

>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.

Just use mkon$p or mkonu$ (or the condition statment in a pl1 routine)
to create a handler for the cleanup$ condition.  Any non-local goto
("longjump") through the stack frame will cause the handler to be
called.  (Unless, of course, your not running primos.  :-) (There are
occasional advantages to huge microcode supported calling sequences.)
[Please note before flaming me: this to contrast the messages that
always assume vax/unix.  If you must flame, do so by mail.  I do agree
with the statement above if "portable" is inserted between "NO" and
"WAY".]

--
Bob Larson	Arpa: Blarson at Ecla.Usc.Edu	blarson at skat.usc.edu
Uucp: {sdcrdcf,cit-vax}!oberon!skat!blarson
Prime mailing list:	info-prime-request%fns1 at ecla.usc.edu
			oberon!fns1!info-prime-request



More information about the Comp.lang.c mailing list