• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Catching system signals and exception handling
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Catching system signals and exception handling


  • Subject: Catching system signals and exception handling
  • From: Aaron Burghardt <email@hidden>
  • Date: Thu, 21 Jul 2005 11:03:38 -0400

Hi All,

I'm trying to learn how handle system signals so I can catch SIGBUS & SIGSEGV signals, report them, and possibly recover from them. I've tried using the NSExceptionHandler from the ExceptionHandling framework, but I can't get it to catch signals and convert to exceptions, so I've moved on to installing my own signal handler.

I would like to have my signal handler create and raise an NSException. My test app will do it once, but subsequent signals get caught in an infinite loop. Is there a way to do this? Do I need to use setjmp/longjmp?

Thanks,

Aaron

Below is the condensed version of my test app.

- (void)awakeFromNib
{
    initializeSignalHandler();
}


- (IBAction)generateBusError:(id)sender; { id myObject = 0x0A; [myObject release]; }


void initializeSignalHandler( void ) { NSLog(@"Registering signal handler"); signal( SIGBUS, handleSystemSignal); }

void handleSystemSignal( int signal )
{
NSLog(@"Handling system signal");
NSException *exception = [NSException exceptionWithName:@"BASystemSignalException"
reason: [NSString stringWithFormat:@"Unhandled system signal: %i - %s", signal, signalDescription[signal] ]
userInfo: [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:signal], @"Signal", nil]];
[exception raise];
}



Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Catching system signals and exception handling
      • From: j o a r <email@hidden>
  • Prev by Date: Re: NSBezierPath Fill and Stroke woes;
  • Next by Date: Re: NSBezierPath Fill and Stroke woes;
  • Previous by thread: CoreData: Multiple Threads and Merging Object Contexts
  • Next by thread: Re: Catching system signals and exception handling
  • Index(es):
    • Date
    • Thread