Skip to content

Commit

Permalink
cleaner exit
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Mar 14, 2025
1 parent 4a54e01 commit a589bbb
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit a589bbb

Please sign in to comment.