From a589bbb760ecd46ce017982543b3a14a029faa30 Mon Sep 17 00:00:00 2001 From: "Matthew C. Morgan" Date: Fri, 14 Mar 2025 18:13:28 -0400 Subject: [PATCH] cleaner exit --- .../gfl-resource-actions/aws_resource_management.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/local-app/python-tools/gfl-resource-actions/aws_resource_management.py b/local-app/python-tools/gfl-resource-actions/aws_resource_management.py index 5afe76c3..a4d03dde 100644 --- a/local-app/python-tools/gfl-resource-actions/aws_resource_management.py +++ b/local-app/python-tools/gfl-resource-actions/aws_resource_management.py @@ -43,9 +43,13 @@ env = os.environ.copy() env['PYTHONPATH'] = script_dir + os.pathsep + env.get('PYTHONPATH', '') - # Run the command and exit with its return code - result = subprocess.run(cmd, env=env) - sys.exit(result.returncode) + try: + # Run the command and exit with its return code + result = subprocess.run(cmd, env=env) + sys.exit(result.returncode) + except KeyboardInterrupt: + print("\nOperation interrupted by user. Exiting gracefully...") + sys.exit(130) # Standard exit code for SIGINT/Ctrl+C finally: # Clean up the temporary file os.unlink(temp_file.name)