I am using Symfony2 and I want to run a long script written in C++ (for example 60 minutes).
Now I do it via shell_exec()
:
$pid = shell_exec('nohup my/program/written/in/c++.out some arguments > /dev/null 2>/dev/null & echo $!');
If I keep refreshing a page the script runs fine, but if I go AFK the script is terminated with process of PHP server (/usr/bin/php-cgi).
Is there a way to isolate C++ program from PHP server process? With nohup the process has ppid = 1, so it should be isolated, but it is not.
You can look at the Symfony Process Component : http://symfony.com/doc/current/components/process.html
$process = new Process('nohup my/program/written/in/c++.out some arguments');
$process->run();
You will be able to run your process.