PDA

View Full Version : fork/exec equivalent in Qt, let the child continue to run



PhilippM
5th September 2011, 13:37
Hi folks,

I'm looking for a solution to the following problem:
My application downloaded an update for itself, say MyApp_updated.exe. I then want to spawn a child process that closes my MyApp.exe, renames MyApp.exe to MyApp_old.exe, renames MyApp_updated.exe to MyApp.exe and then launches then new MyApp.exe.

On Linux, I would use a combination of fork/execlp and perhaps a shell script.

What would be the Qt-way of doing this, especially so that it works also on Windows?
Especially, how is the child process continue to run after the parent is closed (parent must be closed, otherwise I couldn't move/rename the exe file).

Regards,
Philipp

e8johan
6th September 2011, 07:34
Use QProcess, for instance QProcess::startDetached.