for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Antidot\React;
class Child
{
public static function fork(int $numberOfWorkers, callable $asyncServer, int $numberOfFork = 0): void
$pid = pcntl_fork();
if (-1 === $pid) {
// @fail
die('Fork failed');
exit
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.
}
if (0 === $pid) {
$asyncServer();
pcntl_waitpid($pid, $status);
return;
// @parent
$numberOfWorkers--;
++$numberOfFork;
if ($numberOfWorkers > 0) {
self::fork($numberOfWorkers, $asyncServer, $numberOfFork);
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.