public static function fork($id = 0, callable $childHandler = null)
    {
        $info = [];
        $pid = pcntl_fork();

        if ($pid > 0) {// at parent, get forked child info
            $info = [
                'id' => $id,
                'pid' => $pid,
                'startTime' => time(),
            ];
        } elseif ($pid === 0) { // at child
            $pid = getmypid();

            if ($childHandler) {
                $childHandler($id, $pid);
            }

        } else {
            Cli::stderr("Fork child process failed! exiting.\n");
        }

        return $info;
    }
public static function fork($id = 0, callable $childHandler = null)
    {
        $info = [];
        $pid = pcntl_fork();

        if ($pid > 0) {// at parent, get forked child info
            $info = [
                'id' => $id,
                'pid' => $pid,
                'startTime' => time(),
            ];
        } elseif ($pid === 0) { // at child
            $pid = getmypid();

            if ($childHandler) {
                $childHandler($id, $pid);
            }

        } else {
            Cli::stderr("Fork child process failed! exiting.\n");
        }

        return $info;
    }
public static function fork ( $ id = 0 , callable $ childHandler = null ) { $ info = [ ] ; $ pid = pcntl_fork ( ) ; if ( $ pid > 0 ) { // at parent, get forked child info $ info = [ 'id' => $ id , 'pid' => $ pid , 'startTime' => time ( ) , ] ; } elseif ( $ pid === 0 ) { // at child $ pid = getmypid ( ) ; if ( $ childHandler ) { $ childHandler ( $ id , $ pid ) ; } } else { Cli :: stderr ( "Fork child process failed! exiting.\n" ) ; } return $ info ; }
fork a child process.
@param int $id
@param callable|null $childHandler
param bool $first
@return array
fork a child process .