From a4dbd8d09fcd4fea069308ad09bb99f812ce03dc Mon Sep 17 00:00:00 2001 From: James Lu Date: Tue, 26 Jul 2016 16:16:23 -0700 Subject: [PATCH] control: handle SIGINT for clean shutdown on ctrl-c Closes #280. --- coremods/control.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/coremods/control.py b/coremods/control.py index a94254b..d1b0d26 100644 --- a/coremods/control.py +++ b/coremods/control.py @@ -29,12 +29,13 @@ def _shutdown(irc=None): # Disconnect all our networks. remove_network(ircobj) -def sigterm_handler(_signo, _stack_frame): - """Handles SIGTERM gracefully by shutting down the PyLink daemon.""" - log.info("Shutting down on SIGTERM.") +def sigterm_handler(signo, stack_frame): + """Handles SIGTERM and SIGINT gracefully by shutting down the PyLink daemon.""" + log.info("Shutting down on signal %s." % signo) _shutdown() signal.signal(signal.SIGTERM, sigterm_handler) +signal.signal(signal.SIGINT, sigterm_handler) def _rehash(): """Rehashes the PyLink daemon."""