run() public method

The callback receives the type of output (out or err) and some bytes from the output in real-time. It allows to have feedback from the independent process during execution. The STDOUT and STDERR are also available after the process is finished via the getOutput() and getErrorOutput() methods.
public run ( callable | string | array $callback = null ) : integer
$callback callable | string | array A PHP callback to run whenever there is some output available on STDOUT or STDERR
return integer The exit status code
示例#1
0
 protected function detectProcessorNumberByGrep()
 {
     if (Utils::findBin('grep') && file_exists('/proc/cpuinfo')) {
         $process = new Process('grep -c ^processor /proc/cpuinfo 2>/dev/null');
         $process->run();
         $this->processorNumber = intval($process->getOutput());
         return $this->processorNumber;
     }
     return null;
 }
示例#2
0
文件: Utils.php 项目: phpbrew/phpbrew
 /**
  * @param string $package
  */
 public static function getPkgConfigPrefix($package)
 {
     if (self::findBin('pkg-config')) {
         $cmd = 'pkg-config --variable=prefix ' . $package;
         $process = new Process($cmd);
         $code = $process->run();
         if (intval($code) === 0) {
             $path = trim($process->getOutput());
             if (file_exists($path)) {
                 return $path;
             }
         }
         return false;
     }
     return false;
 }
示例#3
0
 public static function getPkgConfigPrefix($package)
 {
     $cmd = 'pkg-config --variable=prefix ' . $package;
     $process = new Process($cmd);
     $process->run();
     return trim($process->getOutput());
 }