Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!gatech!mcnc!rti!dg-rtp!matrx!wgate!lanzo From: lanzo@wgate.UUCP (Mark Lanzo) Newsgroups: comp.lang.c Subject: Re: longjmp out of signal handler (was Re: alloca() portability) Message-ID: <158@atesysv.UUCP> Date: 16 Nov 90 21:59:27 GMT References: <1990Nov09.233527.7489@chinet.chi.il.us> <27608@mimsy.umd.edu> <15@christmas.UUCP> Reply-To: lanzo@atesysv.UUCP (Mark Lanzo) Organization: Wandel & Goltermann Technologies, Inc. Lines: 47 In a prior article rtm@island.uu.net (Richard Minner) wrote: I was compelled recently (by the devil no doubt) to do this thing. In short: catch_sigsegv(); if (setjmp(sigsegv_jmp_buf) == 0) else release_sigsegv(); ... void handler(sig) int sig; { longjmp(sigsegv_jmp_buf, 1); } Is this really all that unportable and/or unreliable? I asked about this a while back when (I believe) Peter da Silva said it was evil, but no one answered. If it's some kind of secret just say so and I'll understand. I too ran into a situation where I had to do exactly what you have here. Unfortunately, it seems to be the only way to handle some problems (I despise using setjmp/longjmp for anything if it can be avoided). In particular, it was mandatory that I longjmp out of the signal handler since if I returned from the signal handler I got caught in an infinite loop! It seems that the system returns to exactly the same instruction that caused the exception in the first place, thus causing the same error all over again. {is this what it is supposed to do?}. I did however use "_setjmp" and "_longjmp" rather than "setjmp" and "longjmp", because the latter two functions screw around with the process signal mask. My equivalents to your "catch_sigsegv" and "release_sigsegv" did all the setup & restoration of the signal mask and exception vectors (they also trapped SIGBUS in addition to SIGSEGV). Disclaimer: this was under HP-UX 7.0 on HP9000 s300 series. Your mileage may vary. I don't know if "_setjmp" and "_longjmp" are standard things or HP'isms. -- Mark Lanzo | Wandel & Goltermann Technologies, Inc. uunet!wgate!lanzo | 1030 Swabia Court, Research Triangle Park lanzo@wgate.wgate.com ?? | North Carolina 27709-3585 | Phone: (919) 941-5730 FAX: (919) 941-5751