Re: Relaunching App Programmatically - Terminal Window Shows up
Re: Relaunching App Programmatically - Terminal Window Shows up
- Subject: Re: Relaunching App Programmatically - Terminal Window Shows up
- From: "email@hidden" <email@hidden>
- Date: Fri, 6 Feb 2009 14:06:05 +0100
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 <email@hidden> 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 (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
>
_______________________________________________
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