Python signal.SIGQUIT Examples
The following are 30
code examples of signal.SIGQUIT().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
signal
, or try the search function
.
Example #1
Source File: compat.py From bash-lambda-layer with MIT License | 7 votes |
def ignore_user_entered_signals(): """ Ignores user entered signals to avoid process getting killed. """ if is_windows: signal_list = [signal.SIGINT] else: signal_list = [signal.SIGINT, signal.SIGQUIT, signal.SIGTSTP] actual_signals = [] for user_signal in signal_list: actual_signals.append(signal.signal(user_signal, signal.SIG_IGN)) try: yield finally: for sig, user_signal in enumerate(signal_list): signal.signal(user_signal, actual_signals[sig])
Example #2
Source File: worker.py From Galaxy_Plugin_Bethesda with MIT License | 6 votes |
def init_signals(self) -> None: # Set up signals through the event loop API. self.loop.add_signal_handler(signal.SIGQUIT, self.handle_quit, signal.SIGQUIT, None) self.loop.add_signal_handler(signal.SIGTERM, self.handle_exit, signal.SIGTERM, None) self.loop.add_signal_handler(signal.SIGINT, self.handle_quit, signal.SIGINT, None) self.loop.add_signal_handler(signal.SIGWINCH, self.handle_winch, signal.SIGWINCH, None) self.loop.add_signal_handler(signal.SIGUSR1, self.handle_usr1, signal.SIGUSR1, None) self.loop.add_signal_handler(signal.SIGABRT, self.handle_abort, signal.SIGABRT, None) # Don't let SIGTERM and SIGUSR1 disturb active requests # by interrupting system calls signal.siginterrupt(signal.SIGTERM, False) signal.siginterrupt(signal.SIGUSR1, False)
Example #3
Source File: RunJobEdison.py From pilot with Apache License 2.0 | 6 votes |
def sig2exc(sig, frm): """ signal handler """ error = PilotErrors() runJob.setGlobalPilotErrorDiag("!!FAILED!!3000!! SIGTERM Signal %s is caught in child pid=%d!\n" % (sig, os.getpid())) tolog(runJob.getGlobalPilotErrorDiag()) if sig == signal.SIGTERM: runJob.setGlobalErrorCode(error.ERR_SIGTERM) elif sig == signal.SIGQUIT: runJob.setGlobalErrorCode(error.ERR_SIGQUIT) elif sig == signal.SIGSEGV: runJob.setGlobalErrorCode(error.ERR_SIGSEGV) elif sig == signal.SIGXCPU: runJob.setGlobalErrorCode(error.ERR_SIGXCPU) elif sig == signal.SIGBUS: runJob.setGlobalErrorCode(error.ERR_SIGBUS) elif sig == signal.SIGUSR1: runJob.setGlobalErrorCode(error.ERR_SIGUSR1) else: runJob.setGlobalErrorCode(error.ERR_KILLSIGNAL) runJob.setFailureCode(runJob.getGlobalErrorCode) # print to stderr print >> sys.stderr, runJob.getGlobalPilotErrorDiag() raise SystemError(sig)
Example #4
Source File: RunJob.py From pilot with Apache License 2.0 | 6 votes |
def sig2exc(sig, frm): """ signal handler """ error = PilotErrors() runJob.setGlobalPilotErrorDiag("!!FAILED!!3000!! SIGTERM Signal %s is caught in child pid=%d!\n" % (sig, os.getpid())) tolog(runJob.getGlobalPilotErrorDiag()) if sig == signal.SIGTERM: runJob.setGlobalErrorCode(error.ERR_SIGTERM) elif sig == signal.SIGQUIT: runJob.setGlobalErrorCode(error.ERR_SIGQUIT) elif sig == signal.SIGSEGV: runJob.setGlobalErrorCode(error.ERR_SIGSEGV) elif sig == signal.SIGXCPU: runJob.setGlobalErrorCode(error.ERR_SIGXCPU) elif sig == signal.SIGBUS: runJob.setGlobalErrorCode(error.ERR_SIGBUS) elif sig == signal.SIGUSR1: runJob.setGlobalErrorCode(error.ERR_SIGUSR1) else: runJob.setGlobalErrorCode(error.ERR_KILLSIGNAL) runJob.setFailureCode(runJob.getGlobalErrorCode()) # print to stderr print >> sys.stderr, runJob.getGlobalPilotErrorDiag() raise SystemError(sig)
Example #5
Source File: RunJobAnselm.py From pilot with Apache License 2.0 | 6 votes |
def sig2exc(sig, frm): """ signal handler """ error = PilotErrors() runJob.setGlobalPilotErrorDiag("!!FAILED!!3000!! SIGTERM Signal %s is caught in child pid=%d!\n" % (sig, os.getpid())) tolog(runJob.getGlobalPilotErrorDiag()) if sig == signal.SIGTERM: runJob.setGlobalErrorCode(error.ERR_SIGTERM) elif sig == signal.SIGQUIT: runJob.setGlobalErrorCode(error.ERR_SIGQUIT) elif sig == signal.SIGSEGV: runJob.setGlobalErrorCode(error.ERR_SIGSEGV) elif sig == signal.SIGXCPU: runJob.setGlobalErrorCode(error.ERR_SIGXCPU) elif sig == signal.SIGBUS: runJob.setGlobalErrorCode(error.ERR_SIGBUS) elif sig == signal.SIGUSR1: runJob.setGlobalErrorCode(error.ERR_SIGUSR1) else: runJob.setGlobalErrorCode(error.ERR_KILLSIGNAL) runJob.setFailureCode(runJob.getGlobalErrorCode) # print to stderr print >> sys.stderr, runJob.getGlobalPilotErrorDiag() raise SystemError(sig)
Example #6
Source File: main.py From crowbar with MIT License | 6 votes |
def vnclogin(self, ip, port, keyfile): vnc_cmd = "%s -passwd %s %s:%s" % (self.vncviewer_path, keyfile, ip, port) if self.args.verbose == 2: self.logger.output_file("CMD: %s" % vnc_cmd) proc = subprocess.Popen(shlex.split(vnc_cmd), shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) brute = "LOG-VNC: " + ip + ":" + str(port) + " - " + keyfile self.logger.log_file(brute) # For every line out for line in proc.stdout: # Is debug enabled if self.args.debug: self.logger.output_file(line.decode("utf-8").rstrip()) if re.search(self.vnc_success, str(line)): os.kill(proc.pid, signal.SIGQUIT) result = bcolors.OKGREEN + "VNC-SUCCESS: " + bcolors.ENDC + bcolors.OKBLUE + ip + ":" + str( port) + " - " + keyfile + bcolors.ENDC self.logger.output_file(result) Main.is_success = 1 break
Example #7
Source File: RunJobTitan.py From pilot with Apache License 2.0 | 6 votes |
def sig2exc(sig, frm): """ signal handler """ error = PilotErrors() runJob.setGlobalPilotErrorDiag("!!FAILED!!3000!! SIGTERM Signal %s is caught in child pid=%d!\n" % (sig, os.getpid())) tolog(runJob.getGlobalPilotErrorDiag()) if sig == signal.SIGTERM: runJob.setGlobalErrorCode(error.ERR_SIGTERM) elif sig == signal.SIGQUIT: runJob.setGlobalErrorCode(error.ERR_SIGQUIT) elif sig == signal.SIGSEGV: runJob.setGlobalErrorCode(error.ERR_SIGSEGV) elif sig == signal.SIGXCPU: runJob.setGlobalErrorCode(error.ERR_SIGXCPU) elif sig == signal.SIGBUS: runJob.setGlobalErrorCode(error.ERR_SIGBUS) elif sig == signal.SIGUSR1: runJob.setGlobalErrorCode(error.ERR_SIGUSR1) else: runJob.setGlobalErrorCode(error.ERR_KILLSIGNAL) runJob.setFailureCode(runJob.getGlobalErrorCode) # print to stderr print >> sys.stderr, runJob.getGlobalPilotErrorDiag() raise SystemError(sig)
Example #8
Source File: RunJobHopper.py From pilot with Apache License 2.0 | 6 votes |
def sig2exc(sig, frm): """ signal handler """ error = PilotErrors() runJob.setGlobalPilotErrorDiag("!!FAILED!!3000!! SIGTERM Signal %s is caught in child pid=%d!\n" % (sig, os.getpid())) tolog(runJob.getGlobalPilotErrorDiag()) if sig == signal.SIGTERM: runJob.setGlobalErrorCode(error.ERR_SIGTERM) elif sig == signal.SIGQUIT: runJob.setGlobalErrorCode(error.ERR_SIGQUIT) elif sig == signal.SIGSEGV: runJob.setGlobalErrorCode(error.ERR_SIGSEGV) elif sig == signal.SIGXCPU: runJob.setGlobalErrorCode(error.ERR_SIGXCPU) elif sig == signal.SIGBUS: runJob.setGlobalErrorCode(error.ERR_SIGBUS) elif sig == signal.SIGUSR1: runJob.setGlobalErrorCode(error.ERR_SIGUSR1) else: runJob.setGlobalErrorCode(error.ERR_KILLSIGNAL) runJob.setFailureCode(runJob.getGlobalErrorCode) # print to stderr print >> sys.stderr, runJob.getGlobalPilotErrorDiag() raise SystemError(sig)
Example #9
Source File: client.py From pwnableweb with Apache License 2.0 | 6 votes |
def _start_internal(self): self._started = True # Signals for sig in (signal.SIGINT, signal.SIGQUIT, signal.SIGTERM): signal.signal(sig, self.stop) # Setup the browser & xvfb self.xvfb = xvfbwrapper.Xvfb(width=1024, height=768) self.xvfb.start() self.browser = webdriver.Chrome(executable_path=self._chromedriver_path) self._run_event.set() self._stop_event.clear() self._thread = threading.Thread(target=self._wrap_run) self._thread.start() try: while True: time.sleep(self._interval) self._run_event.set() except KeyboardInterrupt: print 'Saw CTRL-C, shutting down.' self.stop()
Example #10
Source File: test_heartbeat.py From simpleflow with MIT License | 6 votes |
def test_heartbeat_process_kill_parent(self): heartbeat = FakeHeartbeat(1000) heartbeater = HeartbeatProcess(heartbeat, interval=0.1) token = uuid4() task = FakeTask('test_task') result_queue = mp.Queue() handler = FakeTaskHandler(heartbeater.run, (token, task), {}, result_queue) handler_process = mp.Process(target=handler) handler_process.start() time.sleep(2) heartbeat_pid = result_queue.get() handler_process.terminate() os.kill(handler_process.pid, signal.SIGQUIT) handler_process.join() time.sleep(2) with self.assertRaises(OSError): os.kill(heartbeat_pid, signal.SIGKILL)
Example #11
Source File: AIWIBoardContext.py From RPiNWR with GNU General Public License v3.0 | 6 votes |
def __enter__(self): # Make sure to cleanup GPIO afterward if not self.__signals_trapped: self.__signals_trapped = True for sig in [signal.SIGQUIT, signal.SIGTERM, signal.SIGTSTP]: if hasattr(signal.getsignal(sig), '__call__'): deleg = signal.getsignal(sig) def delegate(signum, stack): self.__exit__(None, None, None) deleg(signum, stack) signal.signal(sig, delegate) else: def delegate(signum, stack): self.__exit__(None, None, None) signal.signal(sig, delegate) return self
Example #12
Source File: arbiter.py From jbox with MIT License | 6 votes |
def stop(self, graceful=True): """\ Stop workers :attr graceful: boolean, If True (the default) workers will be killed gracefully (ie. trying to wait for the current connection) """ if self.reexec_pid == 0 and self.master_pid == 0: for l in self.LISTENERS: l.close() self.LISTENERS = [] sig = signal.SIGTERM if not graceful: sig = signal.SIGQUIT limit = time.time() + self.cfg.graceful_timeout # instruct the workers to exit self.kill_workers(sig) # wait until the graceful timeout while self.WORKERS and time.time() < limit: time.sleep(0.1) self.kill_workers(signal.SIGKILL)
Example #13
Source File: conftest.py From pglookout with Apache License 2.0 | 6 votes |
def kill(self, force=True, immediate=True): if self.pg is None: return if force: os.kill(self.pg.pid, signal.SIGKILL) elif immediate: os.kill(self.pg.pid, signal.SIGQUIT) else: os.kill(self.pg.pid, signal.SIGTERM) timeout = time.monotonic() + 10 while (self.pg.poll() is None) and (time.monotonic() < timeout): time.sleep(0.1) if not force and self.pg.poll() is None: raise Exception("PG pid {} not dead".format(self.pg.pid)) # NOTE: cannot use 'tmpdir' fixture here, it only works in 'function' scope
Example #14
Source File: RunJobArgo.py From pilot with Apache License 2.0 | 6 votes |
def sig2exc(sig, frm): """ signal handler """ error = PilotErrors() runJob.setGlobalPilotErrorDiag("!!FAILED!!3000!! SIGTERM Signal %s is caught in child pid=%d!\n" % (sig, os.getpid())) tolog(runJob.getGlobalPilotErrorDiag()) if sig == signal.SIGTERM: runJob.setGlobalErrorCode(error.ERR_SIGTERM) elif sig == signal.SIGQUIT: runJob.setGlobalErrorCode(error.ERR_SIGQUIT) elif sig == signal.SIGSEGV: runJob.setGlobalErrorCode(error.ERR_SIGSEGV) elif sig == signal.SIGXCPU: runJob.setGlobalErrorCode(error.ERR_SIGXCPU) elif sig == signal.SIGBUS: runJob.setGlobalErrorCode(error.ERR_SIGBUS) elif sig == signal.SIGUSR1: runJob.setGlobalErrorCode(error.ERR_SIGUSR1) else: runJob.setGlobalErrorCode(error.ERR_KILLSIGNAL) runJob.setFailureCode(runJob.getGlobalErrorCode) # print to stderr print >> sys.stderr, runJob.getGlobalPilotErrorDiag() raise SystemError(sig)
Example #15
Source File: arbiter.py From Flask-P2P with MIT License | 6 votes |
def stop(self, graceful=True): """\ Stop workers :attr graceful: boolean, If True (the default) workers will be killed gracefully (ie. trying to wait for the current connection) """ self.LISTENERS = [] sig = signal.SIGTERM if not graceful: sig = signal.SIGQUIT limit = time.time() + self.cfg.graceful_timeout # instruct the workers to exit self.kill_workers(sig) # wait until the graceful timeout while self.WORKERS and time.time() < limit: time.sleep(0.1) self.kill_workers(signal.SIGKILL)
Example #16
Source File: base.py From Flask-P2P with MIT License | 6 votes |
def init_signals(self): # reset signaling [signal.signal(s, signal.SIG_DFL) for s in self.SIGNALS] # init new signaling signal.signal(signal.SIGQUIT, self.handle_quit) signal.signal(signal.SIGTERM, self.handle_exit) signal.signal(signal.SIGINT, self.handle_quit) signal.signal(signal.SIGWINCH, self.handle_winch) signal.signal(signal.SIGUSR1, self.handle_usr1) signal.signal(signal.SIGABRT, self.handle_abort) # Don't let SIGTERM and SIGUSR1 disturb active requests # by interrupting system calls if hasattr(signal, 'siginterrupt'): # python >= 2.6 signal.siginterrupt(signal.SIGTERM, False) signal.siginterrupt(signal.SIGUSR1, False)
Example #17
Source File: mayhem_9.py From mayhem with MIT License | 6 votes |
def main(): executor = concurrent.futures.ThreadPoolExecutor() loop = asyncio.get_event_loop() signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT, signal.SIGQUIT) for s in signals: loop.add_signal_handler( s, lambda s=s: asyncio.create_task(shutdown(loop, executor, signal=s))) handle_exc_func = functools.partial(handle_exception, executor) loop.set_exception_handler(handle_exc_func) q = queue.Queue() try: loop.create_task(publish(executor, q)) loop.create_task(consume(executor, q)) loop.run_forever() finally: loop.close() logging.info("Successfully shutdown the Mayhem service.")
Example #18
Source File: mayhem_6.py From mayhem with MIT License | 6 votes |
def main(): executor = concurrent.futures.ThreadPoolExecutor() loop = asyncio.get_event_loop() signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT, signal.SIGQUIT) for s in signals: loop.add_signal_handler( s, lambda s=s: asyncio.create_task(shutdown(loop, executor, signal=s))) handle_exc_func = functools.partial(handle_exception, executor) loop.set_exception_handler(handle_exc_func) q = queue.Queue() try: loop.create_task(publish(executor, q)) loop.create_task(consume(executor, q)) loop.run_forever() finally: loop.close() logging.info("Successfully shutdown the Mayhem service.")
Example #19
Source File: mayhem_8.py From mayhem with MIT License | 6 votes |
def main(): executor = concurrent.futures.ThreadPoolExecutor() loop = asyncio.get_event_loop() signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT, signal.SIGQUIT) for s in signals: loop.add_signal_handler( s, lambda s=s: asyncio.create_task(shutdown(loop, executor, signal=s))) handle_exc_func = functools.partial(handle_exception, executor) loop.set_exception_handler(handle_exc_func) q = queue.Queue() try: loop.create_task(publish(executor, q)) loop.create_task(consume(executor, q)) loop.run_forever() finally: loop.close() logging.info("Successfully shutdown the Mayhem service.")
Example #20
Source File: mayhem_3.py From mayhem with MIT License | 6 votes |
def main(): executor = concurrent.futures.ThreadPoolExecutor() loop = asyncio.get_event_loop() signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT, signal.SIGQUIT) for s in signals: loop.add_signal_handler( s, lambda s=s: asyncio.create_task(shutdown(loop, signal=s))) q = queue.Queue() try: loop.create_task(publish(executor, q)) loop.create_task(consume(executor, q)) loop.run_forever() finally: loop.close() logging.info("Successfully shutdown the Mayhem service.")
Example #21
Source File: sig.py From naz with MIT License | 6 votes |
def _signal_handling(logger: logging.Logger, client: naz.Client) -> None: try: loop = asyncio.get_running_loop() except RuntimeError: loop = asyncio.get_event_loop() try: for _signal in [signal.SIGHUP, signal.SIGQUIT, signal.SIGTERM]: loop.add_signal_handler( _signal, functools.partial( asyncio.ensure_future, _handle_termination_signal(logger=logger, _signal=_signal, client=client), ), ) except ValueError as e: logger.log( logging.DEBUG, { "event": "naz.cli.signals", "stage": "end", "state": "this OS does not support the said signal", "error": str(e), }, )
Example #22
Source File: mayhem_5.py From mayhem with MIT License | 6 votes |
def main(): executor = concurrent.futures.ThreadPoolExecutor() loop = asyncio.get_event_loop() signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT, signal.SIGQUIT) for s in signals: loop.add_signal_handler( s, lambda s=s: asyncio.create_task(shutdown(loop, executor, signal=s))) q = queue.Queue() try: loop.create_task(publish(executor, q)) loop.create_task(consume(executor, q)) loop.run_forever() finally: loop.close() logging.info("Successfully shutdown the Mayhem service.")
Example #23
Source File: recipe-579074.py From code with MIT License | 6 votes |
def _install_signal_handlers(self): """Install signal handlers for the process. """ self._log.info('Installing signal handlers') def handler(signum, _): """Signal handler. """ self._log.info('Got signal %s', signum) self._stop_event.set() for sig in (signal.SIGHUP, signal.SIGINT, signal.SIGTERM, signal.SIGQUIT, signal.SIGABRT): signal.signal(sig, handler)
Example #24
Source File: mayhem_4.py From mayhem with MIT License | 6 votes |
def main(): executor = concurrent.futures.ThreadPoolExecutor() loop = asyncio.get_event_loop() signals = (signal.SIGHUP, signal.SIGTERM, signal.SIGINT, signal.SIGQUIT) for s in signals: loop.add_signal_handler( s, lambda s=s: asyncio.create_task(shutdown(loop, executor, signal=s))) q = queue.Queue() try: loop.create_task(publish(executor, q)) loop.create_task(consume(executor, q)) loop.run_forever() finally: loop.close() logging.info("Successfully shutdown the Mayhem service.")
Example #25
Source File: main.py From levye with MIT License | 6 votes |
def openvpnlogin(self, host, username, password, brute_file, port): brute_file_name = brute_file.name brute_file.seek(0) openvpn_cmd = "%s --config %s --auth-user-pass %s --remote %s %s"% (self.openvpn_path, self.args.config, brute_file_name, host, port) proc = subprocess.Popen(shlex.split(openvpn_cmd), shell=False, stdout = subprocess.PIPE, stderr = subprocess.PIPE) brute = "LOG: OPENVPN: " + host + ":" + username + ":" + password + ":" + brute_file_name + "\n" self.fd_log_file.write(brute) for line in iter(proc.stdout.readline, ''): if re.search(self.vpn_success, line): now = datetime.datetime.now() result = "SUCCESS," + now.strftime("%Y-%m-%d %H:%M:%S") + "," + "OPENVPN," + host + "," + username + "," + password + "\n" print result[:-1] self.fd_output_file.write(result) os.kill(proc.pid, signal.SIGQUIT) brute_file.close()
Example #26
Source File: _server.py From sagemaker-containers with Apache License 2.0 | 6 votes |
def _add_sigterm_handler(nginx, gunicorn): """Placeholder docstring""" def _terminate(signo, frame): # pylint: disable=unused-argument if nginx: try: os.kill(nginx.pid, signal.SIGQUIT) except OSError: pass try: os.kill(gunicorn.pid, signal.SIGTERM) except OSError: pass signal.signal(signal.SIGTERM, _terminate)
Example #27
Source File: serve.py From sagemaker-tensorflow-serving-container with Apache License 2.0 | 6 votes |
def _stop(self, *args): # pylint: disable=W0613 self._state = 'stopping' log.info('stopping services') try: os.kill(self._nginx.pid, signal.SIGQUIT) except OSError: pass try: if self._gunicorn: os.kill(self._gunicorn.pid, signal.SIGTERM) except OSError: pass try: os.kill(self._tfs.pid, signal.SIGTERM) except OSError: pass self._state = 'stopped' log.info('stopped')
Example #28
Source File: __init__.py From aws_logging_handlers with MIT License | 5 votes |
def _teardown(self, signum: int, frame): self.close() if signum == signal.SIGTERM: self._sigterm_handler(signum, frame) elif signum == signal.SIGINT: self._sigint_handler(signum, frame) elif signum == signal.SIGQUIT: self._sigquit_handler(signum, frame)
Example #29
Source File: pp_support.py From me-ica with GNU Lesser General Public License v2.1 | 5 votes |
def _shutdown(self): """Shutdown all slaves.""" for ssh_proc in self._ssh_procs: os.kill(ssh_proc.pid, signal.SIGQUIT) super(NetworkPPScheduler, self)._shutdown() if self.verbose: print "All slaves shut down."
Example #30
Source File: test_executor_kill.py From mirakuru with GNU Lesser General Public License v3.0 | 5 votes |
def test_custom_signal_kill(): """Start process and shuts it down using signal SIGQUIT.""" executor = SimpleExecutor(SLEEP_300, sig_kill=signal.SIGQUIT) executor.start() assert executor.running() is True executor.kill() assert executor.running() is False