• 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
Best way to ensure prevent multiplying helper tasks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Best way to ensure prevent multiplying helper tasks
      • From: John Stiles <email@hidden>
  • Prev by Date: Re: Crash in CFStringHash - can I do anything about this?
  • Next by Date: Re: Best way to ensure prevent multiplying helper tasks
  • Previous by thread: Re: Whre find safari style tabs in IB
  • Next by thread: Re: Best way to ensure prevent multiplying helper tasks
  • Index(es):
    • Date
    • Thread