From 58def9abf1ac3c7476262f37fcd176723f324dec Mon Sep 17 00:00:00 2001 From: Michael Als Date: Wed, 27 Sep 2023 12:54:33 +0000 Subject: [PATCH] Sleep for 1 ms while waiting to yield CPU --- src/Process.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Process.php b/src/Process.php index 8d63e26..38460eb 100644 --- a/src/Process.php +++ b/src/Process.php @@ -47,6 +47,9 @@ public function wait($timeout = 0) $data["err"] .= fread($this->stderr, 8192); $procInfo = proc_get_status($this->handle); $running = $procInfo["running"]; + if ($running) { + usleep(1000); // Sleep 1ms to yield CPU time + } } return $data; }