def __del__(self): ret = self._proc.poll() if ret is None: os.kill(self._proc.pid, signal.SIGKILL) self._proc.wait() elif ret < 0: _log.info('Filter %s exited on %s', self, signalname(-ret)) elif ret > 0: _log.info('Filter %s exited with status %d', self, ret)
def __del__(self): # try a 'gentle' shutdown first try: self._fout.close() os.kill(self._proc.pid, signal.SIGTERM) time.sleep(1) except (OSError, IOError): pass ret = self._proc.poll() if ret is None: os.kill(self._proc.pid, signal.SIGKILL) self._proc.wait() elif ret < 0: _log.info('Filter %s exited on %s', self, signalname(-ret)) elif ret > 0: _log.info('Filter %s exited with status %d', self, ret)
def _child_exited(self, _sig, _frame): '''Signal handler for SIGCHLD.''' while True: try: pid, status = os.waitpid(-1, os.WNOHANG) except OSError: # No child processes break if pid == 0: # No exited processes break if os.WIFSIGNALED(status): _log.info('PID %d exited on %s', pid, signalname(os.WTERMSIG(status))) else: _log.info('PID %d exited with status %d', pid, os.WEXITSTATUS(status)) self._cleanup_child(pid)
def __init__(self, sig): BaseException.__init__(self) self.signal = sig self.signame = signalname(sig)