public function fork()
    {
        $pair = $this->pair();

        $pid = pcntl_fork();
        if ($pid < 0) {  // Failed fork
            throw new \RuntimeException('Failed to fork child process.');
        } elseif ($pid === 0) {  // is worker process
            fclose($pair[0]);
            foreach ($this->sockets as $socket) {
                fclose($socket);
            }
            $this->sockets = array();
            $this->loop($pair[1]);
            exit;
        }

        fclose($pair[1]);
        $this->sockets[$pid] = $pair[0];

        return $pid;
    }
public function fork()
    {
        $pair = $this->pair();

        $pid = pcntl_fork();
        if ($pid < 0) {  // Failed fork
            throw new \RuntimeException('Failed to fork child process.');
        } elseif ($pid === 0) {  // is worker process
            fclose($pair[0]);
            foreach ($this->sockets as $socket) {
                fclose($socket);
            }
            $this->sockets = array();
            $this->loop($pair[1]);
            exit;
        }

        fclose($pair[1]);
        $this->sockets[$pid] = $pair[0];

        return $pid;
    }
public function fork ( ) { $ pair = $ this -> pair ( ) ; $ pid = pcntl_fork ( ) ; if ( $ pid < 0 ) { // Failed fork throw new \ RuntimeException ( 'Failed to fork child process.' ) ; } elseif ( $ pid === 0 ) { // is worker process fclose ( $ pair [ 0 ] ) ; foreach ( $ this -> sockets as $ socket ) { fclose ( $ socket ) ; } $ this -> sockets = array ( ) ; $ this -> loop ( $ pair [ 1 ] ) ; exit ; } fclose ( $ pair [ 1 ] ) ; $ this -> sockets [ $ pid ] = $ pair [ 0 ] ; return $ pid ; }
Start a worker process.

@return  int  Forked process ID
Start a worker process .