diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2013-06-26 09:15:40 -0500 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2013-06-26 09:15:40 -0500 |
commit | 8b49d8b198564d0dae3e40b99b6f9d76188dcda7 (patch) | |
tree | 32215bc2e1354aff55e731875890554d315bed10 /tools/bcfg2-profile-templates.py | |
parent | 50e8555aac2830ca2b848003a811b1b418fd0f79 (diff) | |
download | bcfg2-8b49d8b198564d0dae3e40b99b6f9d76188dcda7.tar.gz bcfg2-8b49d8b198564d0dae3e40b99b6f9d76188dcda7.tar.bz2 bcfg2-8b49d8b198564d0dae3e40b99b6f9d76188dcda7.zip |
Revert "Core: properly handle Ctrl-C"
This reverts commit 4568c44372c99ba809826e016680da9b881bd8e8.
Trying to handle ^c in the core is difficult and can break STDOUT for
interactive programs that invoke the core.
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Conflicts:
src/lib/Bcfg2/Server/Core.py
src/sbin/bcfg2-test
tools/bcfg2-profile-templates.py
Diffstat (limited to 'tools/bcfg2-profile-templates.py')
-rwxr-xr-x | tools/bcfg2-profile-templates.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/bcfg2-profile-templates.py b/tools/bcfg2-profile-templates.py index 93314f1e3..f4069e454 100755 --- a/tools/bcfg2-profile-templates.py +++ b/tools/bcfg2-profile-templates.py @@ -5,6 +5,7 @@ import sys import time import math +import signal import logging import operator import Bcfg2.Logger @@ -17,6 +18,19 @@ def stdev(nums): return math.sqrt(sum((n - mean)**2 for n in nums) / float(len(nums))) +def get_sigint_handler(core): + """ Get a function that handles SIGINT/Ctrl-C by shutting down the + core and exiting properly.""" + + def hdlr(sig, frame): # pylint: disable=W0613 + """ Handle SIGINT/Ctrl-C by shutting down the core and exiting + properly. """ + core.shutdown() + os._exit(1) # pylint: disable=W0212 + + return hdlr + + def main(): optinfo = dict( client=Bcfg2.Options.Option("Benchmark templates for one client", @@ -49,6 +63,7 @@ def main(): logger = logging.getLogger(sys.argv[0]) core = Bcfg2.Server.Core.BaseCore(setup) + signal.signal(signal.SIGINT, get_sigint_handler(core)) logger.info("Bcfg2 server core loaded") core.load_plugins() logger.debug("Plugins loaded") |