public function getWorkState($wait = false)
    {
        if (!is_null($this->workPid)) {
            if (!posix_kill($this->workPid, 0)) {
                $this->workState = self::FAILED;
                $this->workPid = null;
            } else {
                $status = null;

                if ($wait === true) {
                    $args = null;
                } else {
                    $args = \WNOHANG;
                }
                $exitPid = pcntl_waitpid($this->workPid, $status, $args);

                if ($exitPid == $this->workPid) {
                    $this->workState = self::FAILED;
                    if (pcntl_wifexited($status)) {
                        if (pcntl_wexitstatus($status) == 0) {
                            $this->workState = self::COMPLETE;
                        }
                    }
                    $this->workPid = null;
                }
            }
        }

        return $this->workState;
    }