diff options
author | OpenGnSys Support Team <soporte-og@soleta.eu> | 2023-11-30 21:48:14 +0100 |
---|---|---|
committer | OpenGnSys Support Team <soporte-og@soleta.eu> | 2023-11-30 22:22:42 +0100 |
commit | b91ab6ef7813a313e1944e8d01057414166962d8 (patch) | |
tree | 336c86ca7a0ce22d22a4b0e9ac5cd8f856788cab | |
parent | da8f8e8009741e92d5e5fd08b9a30bea96a385fb (diff) |
ogcli: add SIGINT handler
if user presses ctrl-c, interrupt ongoing operation to avoid python backtrace.
-rwxr-xr-x | ogcli | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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) |