Re: Relaunching an application
Re: Relaunching an application
- Subject: Re: Relaunching an application
- From: "Michael Ash" <email@hidden>
- Date: Tue, 4 Mar 2008 11:11:43 -0500
On Mon, Mar 3, 2008 at 9:27 PM, Joe Ranieri <email@hidden> wrote:
> Maybe I'm missing something, but....
>
> Instead of NSTask, why not use LSOpenApplication passing in
> (kLSLaunchDefaults | kLSLaunchNewInstance | kLSLaunchDontAddToRecents)
> for flags? Your main program will block until the sub program has
> launched.
There are two problems with this. First, the new instance of the app
will not have functional Services, if it happens to export any. The
registration will be blocked because the first app is still around.
Second, the new instance will get a new Dock icon. This is very ugly
if the app has a permanent place in the dock, since you'll end up with
two icons, one non-running icon in the middle somewhere, and one
running icon at the end.
On another note, a couple of people have proposed ideas where a
subtask sits around watching for application terminated notifications,
then relaunches based on that. This is a fine approach, although IMO
more complex than my technique of sitting on a pipe. However, after
you sign up for the notification you must be sure to check to see if
the parent app is still around, because it could have quit already.
This is unlikely but it's possible, so a proper implementation of this
technique needs to handle that case. This is another reason I prefer
the pipe technique, as it will always work no matter when the parent
app terminates. The Sparkle code which Mattias Arrelid linked to
appears to handle this properly, although mixing NSWorkspace
notifications with POSIX process management makes me slightly
paranoid.
Mike
_______________________________________________
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