You don't need a helper app for this.

- (void) relaunch
{
        int processIdentifier = [[NSProcessInfo processInfo] processIdentifier];
        NSString *myPath = [NSString stringWithFormat:@"%s",
        [[[NSBundle mainBundle] executablePath] fileSystemRepresentation]];
        [NSTask launchedTaskWithLaunchPath:myPath arguments:[NSArray
arrayWithObject:[NSString stringWithFormat:@"%d",
processIdentifier]]];
        [NSApp terminate:self];
}

HTH
Fabian

On Fri, Feb 6, 2009 at 7:40 AM, Oleg Krupnov <oleg.krup...@gmail.com> wrote:
> I want to have the ability to relaunch my app programmatically, e.g.
> after update or crash. I have checked the Sparkle Update's
> implementation of relaunch and I found a little helper app called
> "relaunch" (put into Resources). The main executable launches the
> helper app passing its own path and process id in parameters. Then the
> main executable terminates and the helper app waits for that by
> polling until the main process id becomes invalid. Then the helper app
> relaunches the main app using -[NSWorkspace openFile].
>
> This seems to be a good implementation (correct me if I'm wrong) and
> it works like a charm in Sparkle Update (sparkle.andymatuschak.org).
> However, when I tried to reuse this "relaunch" helper app, it does
> work, but I've got a weird problem: On top of the relaunched main app,
> the Terminal window appears with message:
>
> Last login: Fri Feb  6 08:17:53 on ttys001
> /[path to the main app] ; exit;
> [my computer name]:~ [user name]$ [path to the main app] ; exit;
>
> When I try to close the terminal window, I've got message: "Closing
> this window will terminate the running processes: login, bash, [my
> app]". And it's not lying :).
>
> I'm not strong in things like console apps, UNIX etc. What am I doing
> wrong? How to prevent the Terminal window from appearing? Thanks!
> _______________________________________________
>
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/slasktrattenator%40gmail.com
>
> This email sent to slasktrattena...@gmail.com
>
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to