public function killAndWait()
    {
        $status = 0;
        $this->kill();
        if ($this->pid > 0) {
            $pid = pcntl_wait($status);
            if ($pid == $this->pid) {
                $this->pid = -1;
            }
        }
    }