home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / programm / 4027 < prev    next >
Encoding:
Text File  |  1992-07-30  |  1.9 KB  |  72 lines

  1. Newsgroups: comp.unix.programmer
  2. Path: sparky!uunet!csfb1!sstakoff
  3. From: sstakoff@csfb1.fir.fbc.com (Stuart Stakoff)
  4. Subject: Signal handlers and longjmp() 
  5. Message-ID: <Bs8DLC.G9o@csfb1.fir.fbc.com>
  6. Keywords: signal longjmp setjmp
  7. Sender: news@csfb1.fir.fbc.com (Usenet News Account)
  8. Reply-To: uunet!csfb1!sstakoff
  9. Organization: First Boston Corporation
  10. Date: Fri, 31 Jul 1992 02:00:47 GMT
  11. Lines: 59
  12.  
  13.  
  14. I am having the following signal handler problem:
  15.  
  16. I want to do some fairly elaborate stuff when a SIGSEGV is detected.  I
  17. don't want to do a lot of processing within the signal handler itself, so
  18. I am using setjmp/longjmp.  For example:
  19.  
  20. jmp_buf env;
  21.  
  22. main()
  23. {
  24.  
  25.  
  26.   signal(SIGSEGV,handler);
  27.  
  28.   if (setjmp(env)) {
  29.     do_stuff();
  30.   }
  31. }
  32.  
  33. handler()
  34. {
  35.   signal(SIGSEGV,SIG_DFL);   // This doesn't seem to have any effect
  36.   
  37.   // Get out of signal handler context and do whatever processing
  38.   // needs to be done for this signal
  39.   longjmp(env,1);
  40. }
  41.  
  42. do_stuff()
  43. {
  44.  
  45.   ... handle the signal
  46.  
  47.   ???? I now want the default handler to be called!
  48. }
  49.  
  50. ------------------------------------------------------------
  51.  
  52. With the above code, when a SEGV is generated, my do_stuff()
  53. routine is called.  I can't seem to get the default signal handler
  54. to be called.  My goal is to handle the signal in my own way and then
  55. have the normal core dump occur.  I have tried playing around
  56. with sigsetmask and sigprocmask but have had no luck.  I would
  57. appreciate any help.
  58.  
  59. Thanks in advance.  
  60.  
  61. Please send replies via email.  I will post a followup.
  62.  
  63. -- 
  64.  
  65.  
  66.    +-------------------------------------------------------------------+
  67.    |   Stuart A. Stakoff           |      sstakoff@csfb1.fir.fbc.com   |
  68.    |   First Boston Corporation    |      uunet!csfb1!sstakoff         |
  69.    |   (212)909-4926               |      (212)688-0913 - FAX          |
  70.    +-------------------------------------------------------------------+
  71.  
  72.