toolong icon indicating copy to clipboard operation
toolong copied to clipboard

issue59: making exit more robust

Open Roobxyz opened this issue 4 months ago • 0 comments

Overview

Explicitly calling sys.exit when ctrl-C is pressed. Finally block ensures termination of reading /dev/tty. Better signal handling on interupt.

Changes

  • src/toolong/cli.py

Signal Handling Enhancements:

  • Improved the request_exit function to handle termination signals more gracefully by using sys.exit(0)

  • Added a try-except-finally block to handle KeyboardInterrupt and ensure the process is properly terminated by calling process.terminate() and process.wait().

Minor Adjustments:

  • moved import sys inside the run, this might be unnecessary but I was getting "sys" referenced before assignment if I left it at global...

Roobxyz avatar Sep 30 '24 20:09 Roobxyz