diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2022-05-18 07:18:51 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2022-05-18 07:18:51 -0400 |
commit | 803a5494ef23187e920eeb4b42e922b87cda5966 (patch) | |
tree | 141923268aef69c8b66324977160f60a7b1e7b24 /coverage/control.py | |
parent | cde33ba4ded948bfc1fc9c6768db35d7728102c2 (diff) | |
download | python-coveragepy-git-803a5494ef23187e920eeb4b42e922b87cda5966.tar.gz |
fix: the SIGTERM handler is now opt-in. #1310
Diffstat (limited to 'coverage/control.py')
-rw-r--r-- | coverage/control.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/coverage/control.py b/coverage/control.py index 6387d0dd..a0571c97 100644 --- a/coverage/control.py +++ b/coverage/control.py @@ -536,12 +536,13 @@ class Coverage: # Register our clean-up handlers. atexit.register(self._atexit) - is_main = (threading.current_thread() == threading.main_thread()) - if is_main and not env.WINDOWS: - # The Python docs seem to imply that SIGTERM works uniformly even - # on Windows, but that's not my experience, and this agrees: - # https://stackoverflow.com/questions/35772001/x/35792192#35792192 - self._old_sigterm = signal.signal(signal.SIGTERM, self._on_sigterm) + if self.config.sigterm: + is_main = (threading.current_thread() == threading.main_thread()) + if is_main and not env.WINDOWS: + # The Python docs seem to imply that SIGTERM works uniformly even + # on Windows, but that's not my experience, and this agrees: + # https://stackoverflow.com/questions/35772001/x/35792192#35792192 + self._old_sigterm = signal.signal(signal.SIGTERM, self._on_sigterm) def _init_data(self, suffix): """Create a data file if we don't have one yet.""" |