Skip to content

Commit

Permalink
Sleep for 1 ms while waiting to yield CPU
Browse files Browse the repository at this point in the history
  • Loading branch information
mal-risma committed Sep 27, 2023
1 parent 2de7ef7 commit 58def9a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 58def9a

Please sign in to comment.