home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.programmer
- Path: sparky!uunet!csfb1!sstakoff
- From: sstakoff@csfb1.fir.fbc.com (Stuart Stakoff)
- Subject: Signal handlers and longjmp()
- Message-ID: <Bs8DLC.G9o@csfb1.fir.fbc.com>
- Keywords: signal longjmp setjmp
- Sender: news@csfb1.fir.fbc.com (Usenet News Account)
- Reply-To: uunet!csfb1!sstakoff
- Organization: First Boston Corporation
- Date: Fri, 31 Jul 1992 02:00:47 GMT
- Lines: 59
-
-
- I am having the following signal handler problem:
-
- I want to do some fairly elaborate stuff when a SIGSEGV is detected. I
- don't want to do a lot of processing within the signal handler itself, so
- I am using setjmp/longjmp. For example:
-
- jmp_buf env;
-
- main()
- {
-
-
- signal(SIGSEGV,handler);
-
- if (setjmp(env)) {
- do_stuff();
- }
- }
-
- handler()
- {
- signal(SIGSEGV,SIG_DFL); // This doesn't seem to have any effect
-
- // Get out of signal handler context and do whatever processing
- // needs to be done for this signal
- longjmp(env,1);
- }
-
- do_stuff()
- {
-
- ... handle the signal
-
- ???? I now want the default handler to be called!
- }
-
- ------------------------------------------------------------
-
- With the above code, when a SEGV is generated, my do_stuff()
- routine is called. I can't seem to get the default signal handler
- to be called. My goal is to handle the signal in my own way and then
- have the normal core dump occur. I have tried playing around
- with sigsetmask and sigprocmask but have had no luck. I would
- appreciate any help.
-
- Thanks in advance.
-
- Please send replies via email. I will post a followup.
-
- --
-
-
- +-------------------------------------------------------------------+
- | Stuart A. Stakoff | sstakoff@csfb1.fir.fbc.com |
- | First Boston Corporation | uunet!csfb1!sstakoff |
- | (212)909-4926 | (212)688-0913 - FAX |
- +-------------------------------------------------------------------+
-
-