Restart program

8 posts / 0 new
Last post
mritter0
mritter0's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2014-04-21 21:15
Restart program

When AmiStore has an update it downloads, installs, and restarts. How is it quitting and restarting itself?

gazelle
gazelle's picture
Offline
Last seen: 1 year 9 months ago
Joined: 2011-04-13 12:52
Re: Restart program

My guess would be: With an helper programm it spawns before exiting.

xenic
xenic's picture
Offline
Last seen: 2 years 7 months ago
Joined: 2011-05-07 04:52
Re: Restart program

@mritter0
I haven't tried it but it could do something like this:

Old Amistore checks that a certain environmental variable isn't set.
Old Amistore sets the variable containing it's version.
Old Amistore downloads the new version and starts it.
New Amistore finds the variable and determines an old version is running.
New Amistore waits for the variable to be removed within a specified time.
Old Amistore cleans up, executes Forbid(), removes the variable and exits.
New AmiStore detects that the variable is gone and sets it's own variable.
New AmiStore completes it's startup and opens.

X1000 - OS 4.1FE

thomas
thomas's picture
Offline
Last seen: 3 months 1 week ago
Joined: 2011-05-16 14:23
Re: Restart program

Normally you would just watch for a public MsgPort of the program, send a SIGBREAKF_CTRL_C signal to its mp_SigTask and wait until the port disappears. Then you can run the new version.

If the port is an ARexx port you can use an ARexx command to quit the program instead of Ctrl-C.

Or whatever makes the program quit. It's your program, you should know.

TSK
TSK's picture
Offline
Last seen: 1 year 1 month ago
Joined: 2011-06-28 02:06
Re: Restart program

Just start the new one with SystemTags() and then quit yourself.

jabirulo
jabirulo's picture
Offline
Last seen: 3 weeks 23 hours ago
Joined: 2013-05-30 00:53
Re: Restart program

Make your program create a script and save it to T: that waits a couple of seconds and re-run program. Such script should be run async from your program before quitting.

'T:myown.script'
C:Wait 2 SECS
path_to_my_program/program_executable

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

hypex
hypex's picture
Offline
Last seen: 3 months 3 weeks ago
Joined: 2011-09-09 16:20
Re: Restart program

I suppose you could add a new process and make it reachable with a message port. This would then wait for a signal or message. You then begin the process of closing down your program. When done you signal the process this is complete. Which then reopens your program and exits itself. Now, for this to work, you would need isolate and copy code for the new process so not too easy.

Perhaps easiest is to do similar but get code to spawn a new copy of your program, possibly with a WB API to relaunch it. Then exit the sub process and main process.

Also possible would be to simply close down your program to the last line of code. Then use DOS API to restart it. Exit.

mritter0
mritter0's picture
Offline
Last seen: 2 years 5 months ago
Joined: 2014-04-21 21:15
Re: Restart program

Thanks for the ideas, guys.

Log in or register to post comments