This commit is contained in:
Tobias Schultze 2012-04-23 14:43:49 +03:00
parent 27b4774ff3
commit 885104cb78

View File

@ -48,7 +48,7 @@ class Process
private $status = self::STATUS_READY; private $status = self::STATUS_READY;
private $fileHandles; private $fileHandles;
private $readedBytes; private $readBytes;
/** /**
* Exit codes translation table. * Exit codes translation table.
@ -274,7 +274,7 @@ class Process
foreach ($fh as $type => $fileHandle) { foreach ($fh as $type => $fileHandle) {
fseek($fileHandle, 0); fseek($fileHandle, 0);
$data = fread($fileHandle, 8192); $data = fread($fileHandle, 8192);
$this->readedBytes[$type] = strlen($data); $this->readBytes[$type] = strlen($data);
if (strlen($data) > 0) { if (strlen($data) > 0) {
call_user_func($callback, $type == 1 ? self::OUT : self::ERR, $data); call_user_func($callback, $type == 1 ? self::OUT : self::ERR, $data);
} }
@ -318,7 +318,7 @@ class Process
{ {
$this->processInformation = proc_get_status($this->process); $this->processInformation = proc_get_status($this->process);
$callback = $this->buildCallback($callback); $callback = $this->buildCallback($callback);
while ($this->pipes || (defined('PHP_WINDOWS_VERSION_BUILD') && $this->fileHandles)) { while ($this->pipes || defined('PHP_WINDOWS_VERSION_BUILD') && $this->fileHandles) {
$r = $this->pipes; $r = $this->pipes;
$w = null; $w = null;
$e = null; $e = null;
@ -337,12 +337,12 @@ class Process
if (defined('PHP_WINDOWS_VERSION_BUILD')) { if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$fh = $this->fileHandles; $fh = $this->fileHandles;
foreach ($fh as $type => $fileHandle) { foreach ($fh as $type => $fileHandle) {
fseek($fileHandle, $this->readedBytes[$type]); fseek($fileHandle, $this->readBytes[$type]);
$data = fread($fileHandle, 8192); $data = fread($fileHandle, 8192);
if(isset($this->readedBytes)) { if(isset($this->readBytes)) {
$this->readedBytes[$type] += strlen($data); $this->readBytes[$type] += strlen($data);
} else { } else {
$this->readedBytes[$type] = strlen($data); $this->readBytes[$type] = strlen($data);
} }
if (strlen($data) > 0) { if (strlen($data) > 0) {
@ -719,7 +719,7 @@ class Process
protected function updateOutput() protected function updateOutput()
{ {
if (defined('PHP_WINDOWS_VERSION_BUILD') && isset($this->fileHandles[self::STDOUT]) && is_resource($this->fileHandles[self::STDOUT])) { if (defined('PHP_WINDOWS_VERSION_BUILD') && isset($this->fileHandles[self::STDOUT]) && is_resource($this->fileHandles[self::STDOUT])) {
fseek($this->fileHandles[self::STDOUT], $this->readedBytes[self::STDOUT]); fseek($this->fileHandles[self::STDOUT], $this->readBytes[self::STDOUT]);
$this->addOutput(stream_get_contents($this->fileHandles[self::STDOUT])); $this->addOutput(stream_get_contents($this->fileHandles[self::STDOUT]));
} elseif (isset($this->pipes[self::STDOUT]) && is_resource($this->pipes[self::STDOUT])) { } elseif (isset($this->pipes[self::STDOUT]) && is_resource($this->pipes[self::STDOUT])) {
$this->addOutput(stream_get_contents($this->pipes[self::STDOUT])); $this->addOutput(stream_get_contents($this->pipes[self::STDOUT]));