Usage:
$manager = new \Platformsh\Cli\Util\ProcessManager();
Fork: everything after this will run in a child. The user's shell will
be blocked until the parent is killed.
$manager->fork().
$logFile = 'path/to/logFile';
$log = new \Symfony\Component\Console\Output\StreamOutput(fopen($logFile, 'a'));
Create multiple external processes.
foreach ($commands as $key => $command) {
$process = new \Symfony\Component\Process\Process($command);
$pidFile = 'path/to/pidFile' . $key;
Start the process with the manager.
$manager->startProcess($process, $pidFile, $log);
Report this to the shell.
echo "Started process: " . $process->getCommandLine() . "\n";
}
Kill the parent process to release the shell prompt.
$manager->killParent();
Monitor the external process(es). This keeps them running until the
$pidFile is deleted or they are otherwise stopped.
$manager->monitor();