/**
* Looks into and processes the child's output
*
* @param string $childName
* @return void
*/
public function processOutput($childName)
{
$output = $this->outputBuffer . $this->process->getIncrementalOutput();
$errorOutput = $this->errorOutputBuffer . $this->process->getIncrementalErrorOutput();
$outputLines = explode("\n", $output);
$errorOutputLines = explode("\n", $errorOutput);
if (count($outputLines) > 0) {
$lastItem = array_pop($outputLines);
$this->outputBuffer = $lastItem;
$this->bufferLength += implode("\n", $outputLines);
foreach ($outputLines as $line) {
if (strstr($line, "[[CHILD::BUSY]]")) {
$this->parent->verboseOutput('<info>' . $childName . ' BUSY</info>');
$this->status = ChildProcessContainer::STATUS_BUSY;
} elseif (strstr($line, "[[CHILD::READY]]")) {
$this->parent->verboseOutput('<info>' . $childName . ' READY</info>');
if ($this->status != ChildProcessContainer::STATUS_BUSY_BUT_SLEEPY) {
$this->status = ChildProcessContainer::STATUS_READY;
} else {
$this->status = ChildProcessContainer::STATUS_SLEEPY;
}
} elseif (strlen($line) > 0) {
$this->parent->verboseOutput('<info>OUTPUT ' . $childName . ':</info>' . $line);
}
}
}
if (count($errorOutputLines) > 0) {
$lastItemError = array_pop($errorOutputLines);
$this->errorOutputBuffer = $lastItemError;
$knownErrorOutput = implode("\n", $errorOutputLines);
$this->bufferLength += strlen($knownErrorOutput);
}
}