setEnhanceSigchildCompatibility() public method

Sigchild compatibility mode is required to get the exit code and determine the success of a process when PHP has been compiled with the --enable-sigchild option
public setEnhanceSigchildCompatibility ( boolean $enhance ) : self
$enhance boolean
return self The current Process instance
 /**
  * Starts a wiremock process.
  *
  * @param string $jarPath
  * @param string $logsPath
  * @param string $arguments
  *
  * @throws \Exception
  */
 public function start($ip, $port, $path, $logsPath, $debug)
 {
     $phiremockPath = is_file($path) ? $path : "{$path}/phiremock";
     $this->process = new Process($this->getCommandPrefix() . "{$phiremockPath} -i {$ip} -p {$port}" . ($debug ? ' -d' : ''));
     if ($debug) {
         echo 'Executing: ' . $this->process->getCommandLine() . PHP_EOL;
     }
     $logFile = $logsPath . DIRECTORY_SEPARATOR . self::LOG_FILE_NAME;
     $this->process->start(function ($type, $buffer) use($logFile) {
         file_put_contents($logFile, $buffer, FILE_APPEND);
     });
     $this->process->setEnhanceSigchildCompatibility(true);
     if ($this->isWindows()) {
         $this->process->setEnhanceWindowsCompatibility(true);
     }
 }
示例#2
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;
 }