PHPDaemon\Thread\Generic::start PHP Method

start() public method

Starts the process
public start ( $clearstack = true ) : void
return void
    public function start($clearstack = true)
    {
        $pid = \pcntl_fork();
        if ($pid === -1) {
            throw new \Exception('Could not fork');
        } elseif ($pid === 0) {
            // we are the child
            $thread = $this;
            $thread->pid = \posix_getpid();
            if (!$thread->delayedSigReg) {
                $thread->registerSignals();
            }
            if ($clearstack) {
                throw new ClearStack('', 0, $thread);
            } else {
                $thread->run();
                $thread->shutdown();
            }
        } else {
            // we are the master
            $this->pid = $pid;
        }
    }