Skip to content

Commit

Permalink
Call the previous handler if any and do the default handling if not i…
Browse files Browse the repository at this point in the history
…gnored. Should fix #261.
  • Loading branch information
ionelmc committed Feb 11, 2019
1 parent 9180b5c commit 0cf9aad
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/pytest_cov/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,21 @@ def cleanup(cov=None):

multiprocessing_finish = cleanup # in case someone dared to use this internal

_previous_handler = None

def _sigterm_handler(*_):

def _sigterm_handler(num, frame):
cleanup()
if _previous_handler == signal.SIG_IGN:
pass
elif _previous_handler:
_previous_handler(num, frame)
else:
raise SystemExit(0)


def cleanup_on_sigterm():
global _previous_handler

_previous_handler = signal.getsignal(signal.SIGTERM)
signal.signal(signal.SIGTERM, _sigterm_handler)

0 comments on commit 0cf9aad

Please sign in to comment.