src/Process.php
protected function updateStatus($block = false)
    {
        if ($this->running !== true) {
            return;
        }

        if ($block) {
            $res = pcntl_waitpid($this->pid, $status);
        } else {
            $res = pcntl_waitpid($this->pid, $status, WNOHANG | WUNTRACED);
        }

        if ($res === -1) {
            throw new \RuntimeException('pcntl_waitpid failed. the process maybe available');
        } elseif ($res === 0) {
            $this->running = true;
        } else {
            if (pcntl_wifsignaled($status)) {
                $this->term_signal = pcntl_wtermsig($status);
            }
            if (pcntl_wifstopped($status)) {
                $this->stop_signal = pcntl_wstopsig($status);
            }
            if (pcntl_wifexited($status)) {
                $this->errno = pcntl_wexitstatus($status);
                $this->errmsg = pcntl_strerror($this->errno);
            } else {
                $this->errno = pcntl_get_last_error();
                $this->errmsg = pcntl_strerror($this->errno);
            }
            if (pcntl_wifsignaled($status)) {
                $this->if_signal = true;
            } else {
                $this->if_signal = false;
            }

            $this->running = false;
        }
    }
protected function updateStatus($block = false)
    {
        if ($this->running !== true) {
            return;
        }

        if ($block) {
            $res = pcntl_waitpid($this->pid, $status);
        } else {
            $res = pcntl_waitpid($this->pid, $status, WNOHANG | WUNTRACED);
        }

        if ($res === -1) {
            throw new \RuntimeException('pcntl_waitpid failed. the process maybe available');
        } elseif ($res === 0) {
            $this->running = true;
        } else {
            if (pcntl_wifsignaled($status)) {
                $this->term_signal = pcntl_wtermsig($status);
            }
            if (pcntl_wifstopped($status)) {
                $this->stop_signal = pcntl_wstopsig($status);
            }
            if (pcntl_wifexited($status)) {
                $this->errno = pcntl_wexitstatus($status);
                $this->errmsg = pcntl_strerror($this->errno);
            } else {
                $this->errno = pcntl_get_last_error();
                $this->errmsg = pcntl_strerror($this->errno);
            }
            if (pcntl_wifsignaled($status)) {
                $this->if_signal = true;
            } else {
                $this->if_signal = false;
            }

            $this->running = false;
        }
    }
protected function updateStatus ( $ block = false ) { if ( $ this -> running !== true ) { return ; } if ( $ block ) { $ res = pcntl_waitpid ( $ this -> pid , $ status ) ; } else { $ res = pcntl_waitpid ( $ this -> pid , $ status , WNOHANG | WUNTRACED ) ; } if ( $ res === - 1 ) { throw new \ RuntimeException ( 'pcntl_waitpid failed. the process maybe available' ) ; } elseif ( $ res === 0 ) { $ this -> running = true ; } else { if ( pcntl_wifsignaled ( $ status ) ) { $ this -> term_signal = pcntl_wtermsig ( $ status ) ; } if ( pcntl_wifstopped ( $ status ) ) { $ this -> stop_signal = pcntl_wstopsig ( $ status ) ; } if ( pcntl_wifexited ( $ status ) ) { $ this -> errno = pcntl_wexitstatus ( $ status ) ; $ this -> errmsg = pcntl_strerror ( $ this -> errno ) ; } else { $ this -> errno = pcntl_get_last_error ( ) ; $ this -> errmsg = pcntl_strerror ( $ this -> errno ) ; } if ( pcntl_wifsignaled ( $ status ) ) { $ this -> if_signal = true ; } else { $ this -> if_signal = false ; } $ this -> running = false ; } }
update the process status

@param bool $block
update the process status