New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

relaunch an application in OS X Leopard


Post Reply New Thread Subscribe

 
Thread Tools
jomafaki

 
Member Since: Jun 19, 2009
Posts: 1
jomafaki is on a distinguished road

jomafaki is offline
Hallo all,

I have an application (in C/C++, Carbon) which occasionally downloads itself from an FTP server to the Applications folder (the original application is renamed to .bak). Now I want to relaunch this new version. How can I do that? I have tried following:

1. if the application wants to restart itself, then right before the end of main(), I do execlp("sh", "sh", "-c", "open -a /Applications/MyApp.app", 0);
This doesn't work as soon as I use a socket() call in the application, which I necessarily have to use to download the new version. It doesn't work on both OS X Tiger and Leopard. If I don't use the socket(), it works fine.

2. I tried to fork() and let the child do all the work (GUI and download). The parent waits for the child and if the child exits with return code 42, it does the execlp() to restart. This doesn't work because after the fork() the child actually can't use core-foundation on Leopard.

3. the application does all the work (GUI and download). If it wants to restart, I do fork() and in the child I do execlp(). This works on Tiger but not on Leopard. The same with vfork().

4. so I though fork() after all the work is done is too late. The application first does the fork(). The parent does all the work. The child just waits (read from stdin (0)). When the app wants to restart, the parent kills the child with SIGUSR1 otherwise it kills the child with SIGTERM. The child handles SIGUSR1 and in the handler it execlp() itself. This works on Tiger but not on Leopard.

5. actually should be point 0. I tried the launch services to launch the app, but it doesn't work, because the OS finds that the application is already running, and thus it doesn't re-launch it.

Currently I just show a message telling "new version downloaded, pls restart". Is there a way to re-launch "itself"?

With regards,
Jan
QUOTE Thanks

Post Reply New Thread Subscribe


« Eclipse plugin question | Objective C call main method »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
How to call my own application instead of Phone Application when user press dial? gadget iOS and Apps 0 02-10-2009 07:59 PM
Question about leopard; issues kenneh OS X - Operating System 0 02-07-2009 06:36 PM
Switching to Leopard...Yay or Nay? xj6jaguar1985 Switcher Hangout 12 11-02-2008 01:59 AM
Application has to be transferred in a .sit Aikinai Switcher Hangout 4 10-18-2005 10:19 PM

All times are GMT -4. The time now is 08:12 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?