[Process] Fix process merge in 2.3

Handles should be read and closed after `proc_close` is called.
This commit is contained in:
Romain Neutron 2013-09-11 14:13:56 +02:00
parent 7b2785bc61
commit 19fef77d0d

View File

@ -303,18 +303,6 @@ class Process
}
$this->updateStatus(false);
while ($this->processPipes->hasOpenHandles()) {
usleep(100);
foreach ($this->processPipes->readAndCloseHandles(true) as $type => $data) {
if (3 == $type) {
$this->fallbackExitcode = (int) $data;
} else {
call_user_func($this->callback, $type === self::STDOUT ? self::OUT : self::ERR, $data);
}
}
}
$this->close();
if ($this->processInformation['signaled']) {
if ($this->isSigchildEnabled()) {
throw new RuntimeException('The process has been signaled.');
@ -1062,13 +1050,24 @@ class Process
*/
private function close()
{
$this->processPipes->close();
$exitcode = -1;
if (is_resource($this->process)) {
$exitcode = proc_close($this->process);
}
while ($this->processPipes->hasOpenHandles()) {
usleep(100);
foreach ($this->processPipes->readAndCloseHandles(true) as $type => $data) {
if (3 == $type) {
$this->fallbackExitcode = (int) $data;
} else {
call_user_func($this->callback, $type === self::STDOUT ? self::OUT : self::ERR, $data);
}
}
}
$this->processPipes->close();
$this->exitcode = $this->exitcode !== null ? $this->exitcode : -1;
$this->exitcode = -1 != $exitcode ? $exitcode : $this->exitcode;