--- namcap.py | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/namcap.py b/namcap.py index cca5dd6..f26cdf7 100755 --- a/namcap.py +++ b/namcap.py @@ -19,6 +19,25 @@ # # +# Try to catch ctrl-c in a cleaner way +try: + import signal + def signal_handler(signal, frame): + print("\nInterrupted") + try: + sys.exit(2) + except NameError: + import sys + sys.exit(2) + signal.signal(signal.SIGINT, signal_handler) +except KeyboardInterrupt: + print("\nInterrupted") + try: + sys.exit(1) + except NameError: + import sys + sys.exit(1) + import getopt import imp import os -- 1.7.8