diff options
author | V3n3RiX <venerix@koprulu.sector> | 2023-04-08 22:04:51 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2023-04-08 22:04:51 +0100 |
commit | b359e187fc12c76c3d941b0f1f4b7a48e538cccd (patch) | |
tree | 7a437fa330657baa758c5befffaf16c9cd97310f | |
parent | 718601e0691234edeb4c520ff15b4e6b1c4aa906 (diff) |
setprofile : make sure it stops with keyboard interrupt
-rw-r--r-- | src/backend/setprofile.py | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/src/backend/setprofile.py b/src/backend/setprofile.py index 6219428..5d2f42d 100644 --- a/src/backend/setprofile.py +++ b/src/backend/setprofile.py @@ -2,20 +2,52 @@ import animation import platform +import signal import subprocess +def sigint_handler(signal, frame): + sys.exit(0) + + +signal.signal(signal.SIGINT, sigint_handler) + + @animation.wait('setting up profile') def start(): if platform.uname()[4] == 'x86_64': e_exe = subprocess.Popen( ['eselect', 'profile', 'set', 'default/linux/amd64/17.1/hardened']) - e_exe.wait() + try: + e_exe.wait() + except KeyboardInterrupt: + e_exe.terminate() + try: + e_exe.wait(1) + except subprocess.TimeoutExpired: + e_exe.kill() + sys.exit() if platform.uname()[4] == 'aarch64': e_exe = subprocess.Popen( ['eselect', 'profile', 'set', 'default/linux/arm64/17.0']) - e_exe.wait() + try: + e_exe.wait() + except KeyboardInterrupt: + e_exe.terminate() + try: + e_exe.wait(1) + except subprocess.TimeoutExpired: + e_exe.kill() + sys.exit() env_exe = subprocess.Popen(['env-update'], stdout=subprocess.DEVNULL) - env_exe.wait() + try: + env_exe.wait() + except KeyboardInterrupt: + env_exe.terminate() + try: + env_exe.wait(1) + except subprocess.TimeoutExpired: + env_exe.kill() + sys.exit() |