public function isRunning()
{
if (!is_resource($this->stdout)) {
return FALSE;
}
$this->output .= stream_get_contents($this->stdout);
if ($this->stderr) {
$this->errorOutput .= stream_get_contents($this->stderr);
}
$status = proc_get_status($this->proc);
if ($status['running']) {
return TRUE;
}
fclose($this->stdout);
if ($this->stderr) {
fclose($this->stderr);
}
$code = proc_close($this->proc);
$this->exitCode = $code === self::CODE_NONE ? $status['exitcode'] : $code;
if ($this->interpreter->isCgi() && count($tmp = explode("\r\n\r\n", $this->output, 2)) >= 2) {
list($headers, $this->output) = $tmp;
foreach (explode("\r\n", $headers) as $header) {
$a = strpos($header, ':');
if ($a !== FALSE) {
$this->headers[trim(substr($header, 0, $a))] = (string) trim(substr($header, $a + 1));
}
}
}
return FALSE;
}