Пример #1
0
 /**
  * @param string      $commandline
  * @param null|string $cwd
  * @param null|array  $env
  * @param null|string $input
  * @param int         $timeout
  * @param array       $options
  *
  * @return Process
  */
 private function getProcess($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
 {
     $process = new Process($commandline, $cwd, $env, $input, $timeout, $options);
     if (false !== ($enhance = getenv('ENHANCE_SIGCHLD'))) {
         try {
             $process->setEnhanceSigchildCompatibility(false);
             $process->getExitCode();
             $this->fail('ENHANCE_SIGCHLD must be used together with a sigchild-enabled PHP.');
         } catch (RuntimeException $e) {
             $this->assertSame('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.', $e->getMessage());
             if ($enhance) {
                 $process->setEnhanceSigChildCompatibility(true);
             } else {
                 self::$notEnhancedSigchild = true;
             }
         }
     }
     if (self::$process) {
         self::$process->stop(0);
     }
     return self::$process = $process;
 }