def on_close(self): if self.closed: return self.closed = True if self.fd is not None: self.log.info('Closing fd %d' % self.fd) if getattr(self, 'pid', 0) == 0: self.log.info('pid is 0') return utils.rm_user_info(self.uid, self.pid) try: ioloop.remove_handler(self.fd) except Exception: self.log.error('handler removal fail', exc_info=True) try: os.close(self.fd) except Exception: self.log.debug('closing fd fail', exc_info=True) try: os.kill(self.pid, signal.SIGKILL) os.waitpid(self.pid, 0) except Exception: self.log.debug('waitpid fail', exc_info=True) TermWebSocket.terminals.remove(self) self.log.info('Websocket closed') if self.application.systemd and not len(TermWebSocket.terminals): self.log.info('No more terminals, exiting...') sys.exit(0)
def close(self): if self.closed: return self.closed = True if self.fd is not None: log.info('Closing fd %d' % self.fd) if getattr(self, 'pid', 0) == 0: log.info('pid is 0') return utils.rm_user_info(self.uid, self.pid) try: ioloop.remove_handler(self.fd) except Exception: log.error('handler removal fail', exc_info=True) try: os.close(self.fd) except Exception: log.debug('closing fd fail', exc_info=True) try: os.kill(self.pid, signal.SIGHUP) os.kill(self.pid, signal.SIGCONT) os.waitpid(self.pid, 0) except Exception: log.debug('waitpid fail', exc_info=True) del self.sessions[self.session]