public static function findBin($bin)
{
$path = getenv('PATH');
$paths = explode(PATH_SEPARATOR, $path);
foreach ($paths as $path) {
$f = $path . DIRECTORY_SEPARATOR . $bin;
// realpath will handle file existence or symbolic link automatically
$f = realpath($f);
if ($f !== false) {
return $f;
}
}
return;
}
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; }