public function endProcess()
    {
        if (isset($this->_process)) {
            $error = $this->getError();
            foreach (array_keys($this->_pipes) as $descriptor) {
                $this->closeResource($descriptor);
            }
            $return = proc_close($this->_process);
            if ($return !== 0) {
                throw new CException(sprintf('Process failed with error "%s"', $error), $return);
            }
            $this->_process = null;
            echo "done\n";
            return $return;
        }
        return 0;
    }