in reply to apache2 and system

Maybe your system has a nohup command. So one could try: -
... system('/usr/bin/nohup /path/to/foo'); ...
This will stop the process hanging up when the shell terminates. On some systems nohup produces a nohup.out file in the current directory or your $HOME environment that you may be able to monitor as a web page.