Пример #1
0
 /**
  * @param array $argv
  * @param string|null $outputPath
  *
  * @throws Exception\RuntimeException
  */
 public static function startDaemon(array $argv, $outputPath = null)
 {
     // This part purges the file descriptors of the daemon.
     // Caveat : it may contain "Bashisms", for example if a FD is >= 10.
     $fdPurge = implode(array_map(function ($fd) {
         return ' ' . intval($fd) . '>&-';
     }, IdentificationHelper::getMyFileDescriptors(false)));
     $command = implode(' ', array_map('escapeshellarg', $argv));
     system($command . ' 0</dev/null 1' . ($outputPath !== null ? '>>' . escapeshellarg($outputPath) : '>/dev/null') . ' 2>&1' . $fdPurge . ' &');
 }