Agent: Check _signal_handler before resetting on Windows

We don't need to call win32api.SetConsoleCtrlHandler if _signal_handler
is None (i.e. was never set).
This commit is contained in:
Mike Salvatore 2022-03-21 10:20:34 -04:00
parent a2ac2658ed
commit cda113d291
1 changed files with 2 additions and 1 deletions

View File

@ -71,7 +71,8 @@ def reset_signal_handlers():
if is_windows_os():
import win32api
win32api.SetConsoleCtrlHandler(_signal_handler, False)
if _signal_handler:
win32api.SetConsoleCtrlHandler(_signal_handler, False)
else:
signal.signal(signal.SIGINT, signal.SIG_DFL)
signal.signal(signal.SIGTERM, signal.SIG_DFL)