I have a C++ program, running on Fedora Linux, which has to be able to update itself to a new version, which it can obtain from a server. The way I do this is to have it create a shell script which kills it (the parent process), uninstalls it, downloads the new version (actually it does this first), installs the new version, starts the new version in the background, and deletes itself (the shell script file). I create and run the shell script from the parent program by issuing system commands. I have done this successfully both with system() and popen(). Here is an example:
int i = system\("cd /tmp;/tmp/LTUpdateVersion &"\);
where UpdateVersion is the generated shell script. Here is the problem. Once the parent process is killed, any command in the script which would normally show progress on the screen, such as untarring files, or any echo comands, produce an error message like, "Write error: broken pipe."
How can I generate a shell script from a running process, which then kills the process, but is still able to echo messages to the screen?
Thanks.