Path: utzoo!mnetor!uunet!husc6!mailrus!ames!amdahl!nw From: nw@amdahl.uts.amdahl.com (Neal Weidenhofer) Newsgroups: comp.lang.c Subject: Re: longjmp() from nested signal handlers Message-ID: <26739@amdahl.uts.amdahl.com> Date: 5 Apr 88 21:11:54 GMT References: <4548@june.cs.washington.edu> Organization: Amdahl Corporation, Sunnyvale CA Lines: 30 Summary: longjump from a signal handler ALWAYS results in undefined behavior In article <4548@june.cs.washington.edu>, pardo@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@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