Quit helper app when main app terminates

2012-07-12 Thread Jerry Krinock
What is the best way to make a helper app quit when the associated main app quits (or crashes)? No harm will be done if it keeps running for a minute or so. Thanks, Jerry Krinock ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do

Re: Quit helper app when main app terminates

2012-07-12 Thread Robert Martin
The best way? I have no idea… This is what I do, and it works. I store the path to my helper app in 'path', and do the following when my app is about to quit: //- - (void)applicationWillTerminate:(NSNotification

Re: Quit helper app when main app terminates

2012-07-12 Thread Matt Patenaude
One thing I've done in the past is get the PID of the main app before launching the helper, and pass it as a command line argument to the helper (or something similar) when it's launched. The helper app then periodically polls for the existence of that PID, and when it discovers it's no longer

Re: Quit helper app when main app terminates

2012-07-12 Thread Mark Munz
If you're on 10.6 or later: - (void)applicationWillTerminate:(NSNotification *)aNotification { NSRunningApplication* helperApp = [NSRunningApplication runningApplicationsWithBundleIdentifier:@bundle.id]; [helperApp terminate]; } Sadly, you can't send a terminate command if you're

Re: Quit helper app when main app terminates

2012-07-12 Thread John Harte
On Jul 12, 2012, at 12:33 PM, Jerry Krinock wrote: What is the best way to make a helper app quit when the associated main app quits (or crashes)? No harm will be done if it keeps running for a minute or so. I create a pthread with this code pid_t ppid = getppid ();// get

Re: Quit helper app when main app terminates

2012-07-12 Thread Sean McBride
On Thu, 12 Jul 2012 10:54:13 -0700, Mark Munz said: If you're on 10.6 or later: - (void)applicationWillTerminate:(NSNotification *)aNotification { NSRunningApplication* helperApp = [NSRunningApplication runningApplicationsWithBundleIdentifier:@bundle.id]; [helperApp terminate]; }

Re: Quit helper app when main app terminates

2012-07-12 Thread Stephane Sudre
On Thu, Jul 12, 2012 at 9:33 AM, Jerry Krinock je...@ieee.org wrote: What is the best way to make a helper app quit when the associated main app quits (or crashes)? No harm will be done if it keeps running for a minute or so. A solution that does not involve killing the helper application

Re: Quit helper app when main app terminates

2012-07-12 Thread Mark Munz
Although rare, it is possible to have more than one app with the same bundle id running at the same time. Sorry - I wrote that code in email and mixed up the ProcessIdentifier return type with the BundleIdentifier return type in my head. Correct code for bundle ID should look like this:

Re: Quit helper app when main app terminates

2012-07-12 Thread Jerry Krinock
Thanks for all the ideas. I thought maybe someone would suggest opening up some snazzy inter application communication channel and making the helper exit when it broke (indicating that the main app had terminated). But since that was not offered, I used a combination of the suggestions and

Re: Quit helper app when main app terminates

2012-07-12 Thread Jens Alfke
On Jul 12, 2012, at 9:33 AM, Jerry Krinock je...@ieee.org wrote: What is the best way to make a helper app quit when the associated main app quits (or crashes)? No harm will be done if it keeps running for a minute or so. Take a look at