Re: Exiting non-POSIX threads?
Re: Exiting non-POSIX threads?
- Subject: Re: Exiting non-POSIX threads?
- From: Ken Thomases <email@hidden>
- Date: Mon, 29 Jul 2013 09:54:14 -0500
On Jul 29, 2013, at 4:54 AM, Oleg Krupnov wrote:
> Thanks for your answer, Steve, but the problem remains.
>
> In my case, the exception has already been thrown inside the block and
> I cannot catch it or modify it in any way in my handler. I'm basically
> writing an uncaught exception handler. My app should show a crash
> report window and then terminate itself.
>
> The problem is that if the exception happens in another thread, the
> app gets instantly terminated by the system after my exception handler
> (unlike exceptions in the main thread that are automatically
> absorbed), unless I terminate the crashed thread manually. [NSThread
> exit] worked with NSThreads, but with GCD threads (starting from
> start_wqthread), it's causing the signal.
Look into the ExceptionHandling framework and/or the NSSetUncaughtExceptionHandler() function.
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Exceptions/Tasks/ControllingAppResponse.html#//apple_ref/doc/uid/20000473-BBCHGJIJ
However, you're not supposed to let exceptions escape from blocks which you submit to dispatch queues. That's documented in the link I gave in my previous reply.
If you exit a thread that you don't own, you may screw up your app's ability to present a dialog. Perhaps AppKit relies on that thread. Perhaps the thread held a crucial resource and other threads will deadlock when they try to access it.
All in all, what you're doing seems like a bad idea.
Regards,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden