From b7853f20316e38df6dfbff182f1f6f2d00fdf3cf Mon Sep 17 00:00:00 2001 From: Aidin Gharibnavaz Date: Thu, 15 Sep 2016 18:34:27 +0430 Subject: [PATCH] Issue #3239: Checking signal's default action before handling it. --- certbot/error_handler.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/certbot/error_handler.py b/certbot/error_handler.py index 4e6f6afac..3b5a38031 100644 --- a/certbot/error_handler.py +++ b/certbot/error_handler.py @@ -15,9 +15,14 @@ logger = logging.getLogger(__name__) # potentially occur from inside Python. Signals such as SIGILL were not # included as they could be a sign of something devious and we should terminate # immediately. -_SIGNALS = ([signal.SIGTERM] if os.name == "nt" else - [signal.SIGTERM, signal.SIGHUP, signal.SIGQUIT, - signal.SIGXCPU, signal.SIGXFSZ]) +_SIGNALS = [signal.SIGTERM] +if os.name != "nt": + for signal_code in [signal.SIGTERM, signal.SIGHUP, signal.SIGQUIT, + signal.SIGXCPU, signal.SIGXFSZ]: + # Adding only those signals that their default action is not Ignore. + # This is platform-dependent, so we check it dynamically. + if signal.getsignal(signal_code) != signal.SIG_IGN: + _SIGNALS.append(signal_code) class ErrorHandler(object):