Re: longjmp exit
Re: longjmp exit
- Subject: Re: longjmp exit
- From: Bill Bumgarner <email@hidden>
- Date: Sat, 30 Jul 2005 09:02:31 -0700
On Jul 30, 2005, at 8:35 AM, Roland Silver wrote:
I'm adapting an old C-program to Cocoa. My program uses the longjmp
mechanism to force an exit in case of a serious error. Is there a
different, more appropriate, mechanism in Cocoa?
It depends on how catastrophic of a failure the current longjmp()
mechanism indicates.
If it implies a "friendly termination", which is unlikely, then
invoking -terminate on NSApp will work.
On the other hand, if it means that execution should terminate
immediately without further "high level" execution, then exit() will
work quite well. Even with exit(), there is still the opportunity
for code to be executed to the point where the runloop could be re-
entered.
So, if you really want to ensure that process will quit, use _Exit()
or _exit(). _Exit() will exit immediately without cleanup. _exit()
cleans up quite a bit. Apparently, _exit() cleans up more than exit
(), but will not invoke atexit() handlers.
Finally, if you really want the program to stop execution right then
and there, use abort(). Except abort() can be caught by installing
a SIGABRT handler.
man 3 exit
man _exit
man _Exit
man abort
man sysexits # this will tell you what exit code you should use
b.bum
_______________________________________________
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
References: | |
| >longjmp exit (From: Roland Silver <email@hidden>) |