src/Pcntl/Thread.php
public function start($arguments)
    {
        if (socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $this->sockets) === false) {
            throw  new \Exception(socket_strerror(socket_last_error()));
        }

        $pid = @pcntl_fork();
        if ($pid == -1) {
            $this->fatalError(Thread::COULD_NOT_FORK);
        }
        if ($pid) {
            // parent

            $this->_pid = $pid;
        } else {
            // child
            pcntl_signal(SIGTERM, array($this, 'handleSignal'));

            if (!empty($arguments)) {
                $results = call_user_func_array($this->runnable, $arguments);
            } else {
                $results = call_user_func($this->runnable);
            }

            $data = serialize($results);
            socket_write($this->sockets[0], str_pad($data, $this->message_length), $this->message_length);
            socket_close($this->sockets[0]);

            exit(0);
        }
    }
public function start($arguments)
    {
        if (socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $this->sockets) === false) {
            throw  new \Exception(socket_strerror(socket_last_error()));
        }

        $pid = @pcntl_fork();
        if ($pid == -1) {
            $this->fatalError(Thread::COULD_NOT_FORK);
        }
        if ($pid) {
            // parent

            $this->_pid = $pid;
        } else {
            // child
            pcntl_signal(SIGTERM, array($this, 'handleSignal'));

            if (!empty($arguments)) {
                $results = call_user_func_array($this->runnable, $arguments);
            } else {
                $results = call_user_func($this->runnable);
            }

            $data = serialize($results);
            socket_write($this->sockets[0], str_pad($data, $this->message_length), $this->message_length);
            socket_close($this->sockets[0]);

            exit(0);
        }
    }
public function start ( $ arguments ) { if ( socket_create_pair ( AF_UNIX , SOCK_STREAM , 0 , $ this -> sockets ) === false ) { throw new \ Exception ( socket_strerror ( socket_last_error ( ) ) ) ; } $ pid = @ pcntl_fork ( ) ; if ( $ pid == - 1 ) { $ this -> fatalError ( Thread :: COULD_NOT_FORK ) ; } if ( $ pid ) { // parent $ this -> _pid = $ pid ; } else { // child pcntl_signal ( SIGTERM , array ( $ this , 'handleSignal' ) ) ; if ( ! empty ( $ arguments ) ) { $ results = call_user_func_array ( $ this -> runnable , $ arguments ) ; } else { $ results = call_user_func ( $ this -> runnable ) ; } $ data = serialize ( $ results ) ; socket_write ( $ this -> sockets [ 0 ] , str_pad ( $ data , $ this -> message_length ) , $ this -> message_length ) ; socket_close ( $ this -> sockets [ 0 ] ) ; exit ( 0 ) ; } }
Starts the thread, all the parameters are
passed to the callback function

@return void
Starts the thread all the parameters are passed to the callback function