From 19fef77d0d1ccb75cbba98ca26c69274e28e2d13 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Wed, 11 Sep 2013 14:13:56 +0200 Subject: [PATCH] [Process] Fix process merge in 2.3 Handles should be read and closed after `proc_close` is called. --- src/Symfony/Component/Process/Process.php | 25 +++++++++++------------ 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 98d2bbdf5b..f8edbf75cd 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -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;