PHP fork子进程

$pid = pcntl_fork();
    //这里最好不要有其他的语句
    if ($pid == -1) {
        die('could not fork');
    } else if ($pid) {
        //
        $p[$pid] = 'ok';
        //echo "we are the parent\n";
        //pcntl_wait($status); //Protect against Zombie children
    } else {
        $id = posix_getpid();
        echo "I am the child $id\n";
        abc($i);
        exit(0);
    }
    print_r($p);
原文地址:https://www.cnblogs.com/bugY/p/2450662.html