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.
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; }
/** * @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; }
public static function getPkgConfigPrefix($package) { $cmd = 'pkg-config --variable=prefix ' . $package; $process = new Process($cmd); $process->run(); return trim($process->getOutput()); }