wait2exit(); * } * * @return Zeed_Console_Shutdown_Unix */ public static function getInstance() { if (null === self::$_instance) { self::$_instance = new self(); } return self::$_instance; } /** * 退出信号处理 * * @return void */ public function sigHandler() { if ($this->_allowExit) { $this->_shutdown(); } else { $this->_forceExit = true; } } /** * 检查程序退出 * * @return void */ public function checkExit() { if ($this->_forceExit && $this->_allowExit) { $this->_shutdown(); } } /** * 等待退出 * * @return void */ public function wait2exit() { $this->_allowExit = true; sleep(1); $this->_allowExit = false; } /** * 程序退出 * * @return void */ private function _shutdown() { $note = sprintf('Exit. (Process ID = %s)', getmypid()); if (method_exists('Zeed_Util', 'println')) { Zeed_Util::println($note); Zeed_Util::println('%n'); } else { echo $note; } exit; } }