Re: -forceCancel an NSOperation
Re: -forceCancel an NSOperation
- Subject: Re: -forceCancel an NSOperation
- From: Greg Parker <email@hidden>
- Date: Wed, 01 Mar 2017 15:43:44 -0800
> On Mar 1, 2017, at 3:10 PM, Carl Hoefs <email@hidden> wrote:
>
> This is a multi-tasking server of sorts that runs different analysis algorithms on demand depending on what's requested. But much of the algorithmic code is "hostile" (i.e., student code) so it's unreliable at best. I can firewall against the accvio's with NS_HANDLER et al, but not the hangs and infinite loops. I was just fishing for a nicer solution than kill -9...
The most reliable thing to do is to run the student code as a separate process.
You may be able to make use of alarm(3) or setitimer(2). These functions will send SIGALRM to your process after a specified timeout. That will in turn kill your process if you don't have a handler for that signal. Once the alarm is set there is no need for further interaction from your process, so the timeout will be reliably enforced even if the student code is stuck in a hang or a loop.
I can't argue with the classification of student code as "hostile" and "malicious".
--
Greg Parker email@hidden <mailto:email@hidden> Runtime Wrangler
_______________________________________________
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