Best way to ensure prevent multiplying helper tasks
Best way to ensure prevent multiplying helper tasks
- Subject: Best way to ensure prevent multiplying helper tasks
- From: Daniel Jalkut <email@hidden>
- Date: Fri, 16 Dec 2005 14:11:44 -0500
I'm using NSTask to spawn a "service agent," which gets terminated
when my application quits. On rare occasion, the service agent may
not terminate. Particular during testing, when my application
crashes, the code that would terminate the helper agent never gets
reached.
I want to avoid a worst-case scenario where the user's computer gets
littered with a bunch of processes. Although it seems unlikely to
happen unless my app starts crashing like crazy, I'd still feel more
comfortable if I could guarantee that there is always at most one
helper task.
I can avoid launching a *new* task by simply attempting to connect to
a named service through NSConnection. If I get the connection, then
my task must already be running. Once I have this connection,
though, what's the best way of making sure that it goes away when I'm
done? Can I get an NSTask for an arbitrary NSConnection?
Perhaps the simplest solution would simply be to always launch if the
connection fails, and then have the helper task quit itself if idle
for a certain length of time?
I'd appreciate any wisdom if you have it to share. Thanks!
Daniel
_______________________________________________
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