src/Process.php
public function start()
    {
        if (!empty($this->pid) && $this->isRunning()) {
            throw new \LogicException("the process is already running");
        }

        $callback = $this->getCallable();

        $pid = pcntl_fork();
        if ($pid < 0) {
            throw new \RuntimeException("fork error");
        } elseif ($pid > 0) {
            $this->pid = $pid;
            $this->running = true;
            $this->started = true;
        } else {
            $this->pid = getmypid();
            $this->signal();
            foreach ($this->signal_handlers as $signal => $handler) {
                pcntl_signal($signal, $handler);
            }
            call_user_func($callback);
            exit(0);
        }
    }
public function start()
    {
        if (!empty($this->pid) && $this->isRunning()) {
            throw new \LogicException("the process is already running");
        }

        $callback = $this->getCallable();

        $pid = pcntl_fork();
        if ($pid < 0) {
            throw new \RuntimeException("fork error");
        } elseif ($pid > 0) {
            $this->pid = $pid;
            $this->running = true;
            $this->started = true;
        } else {
            $this->pid = getmypid();
            $this->signal();
            foreach ($this->signal_handlers as $signal => $handler) {
                pcntl_signal($signal, $handler);
            }
            call_user_func($callback);
            exit(0);
        }
    }
public function start ( ) { if ( ! empty ( $ this -> pid ) && $ this -> isRunning ( ) ) { throw new \ LogicException ( "the process is already running" ) ; } $ callback = $ this -> getCallable ( ) ; $ pid = pcntl_fork ( ) ; if ( $ pid < 0 ) { throw new \ RuntimeException ( "fork error" ) ; } elseif ( $ pid > 0 ) { $ this -> pid = $ pid ; $ this -> running = true ; $ this -> started = true ; } else { $ this -> pid = getmypid ( ) ; $ this -> signal ( ) ; foreach ( $ this -> signal_handlers as $ signal => $ handler ) { pcntl_signal ( $ signal , $ handler ) ; } call_user_func ( $ callback ) ; exit ( 0 ) ; } }
start the sub process
and run the callback

@return string pid
start the sub process and run the callback