I want to be able to have an updater application launch the new version of the application, then terminate itself.
开发者_如何学编程When I try the 'usual' of calling the new application via 'system', the updater never exits.
Thoughts?
exec family of functions replaces current process with a new one. If not called from child after fork, this should replace your program with new one.
system calls fork and then executes shell in a child and waits for its return, that's why your updater does not exit.
See man 3 exec and man 3 system.
Look into CreateProcess on Windows or exec on Unix. Use macros to create a wrapper over the OS specific code.
You will need something along the lines of CreateProcess on Windows that creates and runs a separate process. The system
call will wait for whatever command you entered to finish and then return.
精彩评论