From 9d1416ad8290bc54a40c3bb3047369c758018643 Mon Sep 17 00:00:00 2001 From: Ulugbek Miniyarov Date: Sun, 21 Oct 2018 12:15:11 +0300 Subject: [PATCH] [Process] Adds usleep(1000) to ease CPU usage. --- src/Symfony/Component/Process/Process.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Process/Process.php b/src/Symfony/Component/Process/Process.php index 25a4453a39d7d..cb699eb590f4c 100644 --- a/src/Symfony/Component/Process/Process.php +++ b/src/Symfony/Component/Process/Process.php @@ -436,12 +436,10 @@ public function wait(callable $callback = null) * from the output in real-time while writing the standard input to the process. * It allows to have feedback from the independent process during execution. * - * @param callable $callback - * * @throws RuntimeException When process timed out * @throws LogicException When process is not yet started */ - public function waitUntil(callable $callback) + public function waitUntil(callable $callback): bool { $this->requireProcessIsStarted(__FUNCTION__); $this->updateStatus(false); @@ -465,7 +463,14 @@ public function waitUntil(callable $callback) $this->fallbackStatus['exitcode'] = (int) $data; } } + if ($wait && !$this->isRunning()) { + return false; + } + + usleep(1000); } while ($wait); + + return true; } /**