• 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
Re: How to terminate an NSTask whenever my app terminates?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to terminate an NSTask whenever my app terminates?


  • Subject: Re: How to terminate an NSTask whenever my app terminates?
  • From: Doug Hill <email@hidden>
  • Date: Mon, 31 Aug 2015 18:35:41 -0700

Hey Jens,

I ran across this:

Monitoring a Process with a dispatch source <https://developer.apple.com/library/ios/documentation/General/Conceptual/ConcurrencyProgrammingGuide/GCDWorkQueues/GCDWorkQueues.html#//apple_ref/doc/uid/TP40008091-CH103-SW5>

"A process dispatch source lets you monitor the behavior of a specific process and respond appropriately. A parent process might use this type of dispatch source to monitor any child processes it creates. For example, the parent process could use it to watch for the death of a child process. Similarly, a child process could use it to monitor its parent process and exit if the parent process exits."

Good luck!

Doug Hill
http://chartcube.com/ <http://chartcube.com/>


> On Aug 31, 2015, at 4:32 PM, Jens Alfke <email@hidden> wrote:
>
> (I know this has come up here before, but I can’t get the right combination of search terms to find an answer…)
>
> I’m writing a little GUI wrapper app around a command-line-based server. It uses NSTask to launch the server. I want to ensure that when the app exits, the server process exits too. I can tell the NSTask to terminate in my app delegate's -applicationWillTerminate: method, but that doesn’t handle cases where the app crashes or is force-quit.
>
> IIRC there is a way to tell the kernel to terminate the child process when its parent process exits. But what is it, exactly?
>
> —Jens
>
> PS: As far as I know this is unrelated to the SIGHUP mechanism by which shells kill their child processes when they exit; that relies on having a TTY attached to the subprocess.

_______________________________________________

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


References: 
 >How to terminate an NSTask whenever my app terminates? (From: Jens Alfke <email@hidden>)

  • Prev by Date: How to terminate an NSTask whenever my app terminates?
  • Next by Date: NSTableView: Rows from bottom up
  • Previous by thread: How to terminate an NSTask whenever my app terminates?
  • Next by thread: Re: How to terminate an NSTask whenever my app terminates?
  • Index(es):
    • Date
    • Thread