Skip to content

Commit fc7aeb9

Browse files
bug #28940 [Process] Adds usleep(1000) to ease CPU usage. (miniyarov)
This PR was squashed before being merged into the 4.2-dev branch (closes #28940). Discussion ---------- [Process] Adds usleep(1000) to ease CPU usage. | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | symfony/symfony-docs Commits ------- 9d1416a [Process] Adds usleep(1000) to ease CPU usage.
2 parents 717ff2d + 9d1416a commit fc7aeb9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Symfony/Component/Process/Process.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,10 @@ public function wait(callable $callback = null)
436436
* from the output in real-time while writing the standard input to the process.
437437
* It allows to have feedback from the independent process during execution.
438438
*
439-
* @param callable $callback
440-
*
441439
* @throws RuntimeException When process timed out
442440
* @throws LogicException When process is not yet started
443441
*/
444-
public function waitUntil(callable $callback)
442+
public function waitUntil(callable $callback): bool
445443
{
446444
$this->requireProcessIsStarted(__FUNCTION__);
447445
$this->updateStatus(false);
@@ -465,7 +463,14 @@ public function waitUntil(callable $callback)
465463
$this->fallbackStatus['exitcode'] = (int) $data;
466464
}
467465
}
466+
if ($wait && !$this->isRunning()) {
467+
return false;
468+
}
469+
470+
usleep(1000);
468471
} while ($wait);
472+
473+
return true;
469474
}
470475

471476
/**

0 commit comments

Comments
 (0)