public function isAlive()
    {
        if ($this->pid < 1) {
            return false;
        }

        $status = null;
        $pid = pcntl_wait($status, WNOHANG);

        switch ($pid) {
            case -1:
                throw new \RuntimeException('pcntl_wait failed.');

            case $this->pid:
                $this->pid = -1;

                return false;

            case 0:
                return true;
        }

        // Other pid exited.
        return true;
    }