diff --git a/core/redant_main.py b/core/redant_main.py index 0993454e8..d83541c66 100644 --- a/core/redant_main.py +++ b/core/redant_main.py @@ -4,10 +4,13 @@ 2) Tests-to-run list preparation (by test_list_builder). 3) Invocation of the test_runner. """ + +import signal import sys import time import datetime import argparse +from signal_handler import signal_handler from parsing.params_handler import ParamsHandler from test_list_builder import TestListBuilder from test_runner import TestRunner @@ -104,4 +107,8 @@ def main(): if __name__ == '__main__': + + signal.signal(signal.SIGINT, signal_handler) + signal.signal(signal.SIGTSTP, signal_handler) + main() diff --git a/core/signal_handler.py b/core/signal_handler.py new file mode 100644 index 000000000..c7f7fac31 --- /dev/null +++ b/core/signal_handler.py @@ -0,0 +1,18 @@ +""" +This file consists of functions for handling +signals. Signal handling is required for the +graceful exit of the test framework +""" + +def signal_handler(signalNumber, frame): + """ + Function for handling signal and raising the + SystemExit call for graceful exit of the test + framework + Args: + signalNumber (int): The signal number of the signal caught + frame: current stack frame, None or stack frame object. + """ + print("Signal Received",signalNumber) + raise SystemExit('Exiting...') + return