private function run($command, array $arguments)
{
if (!function_exists('proc_open')) {
throw new RuntimeException('The "proc_open" function is not available.');
}
$replacements = array();
foreach ($arguments as $name => $value) {
$replacements['%' . $name . '%'] = ProcessUtils::escapeArgument($value);
}
// Insert quoted arguments
$command = strtr($command, $replacements);
$dspec = array(0 => STDIN, 1 => STDOUT, 2 => STDERR);
$this->running = true;
$proc = proc_open($command, $dspec, $pipes, null, null);
if (is_resource($proc)) {
while (true) {
$status = proc_get_status($proc);
if (!$status['running']) {
break;
}
sleep($this->checkInterval);
}
proc_close($proc);
}
$this->running = false;
return isset($status['exitcode']) ? $status['exitcode'] : 1;
}