From b91ab6ef7813a313e1944e8d01057414166962d8 Mon Sep 17 00:00:00 2001 From: OpenGnSys Support Team Date: Thu, 30 Nov 2023 21:48:14 +0100 Subject: ogcli: add SIGINT handler if user presses ctrl-c, interrupt ongoing operation to avoid python backtrace. --- ogcli | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ogcli b/ogcli index b0edcf3..2738885 100755 --- a/ogcli +++ b/ogcli @@ -17,10 +17,14 @@ import sys OG_CLI_CFG_PATH = "/opt/opengnsys/etc/ogcli.json" +def sigint_handler(signum, frame): + print("User has pressed ctrl-C, interrupting...") + sys.exit(1) class CLI(): def __init__(self): signal.signal(signal.SIGPIPE, signal.SIG_IGN) + signal.signal(signal.SIGINT, sigint_handler) try: with open(OG_CLI_CFG_PATH, 'r') as json_file: self.cfg = json.load(json_file) -- cgit v1.2.3-18-g5258