From e52588b5afdd5bcad700feff50c95a66544b69d6 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 4 Apr 2023 16:04:09 +0000 Subject: [PATCH] term.py: `register_cleanup()` fix --- mmgen/term.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/mmgen/term.py b/mmgen/term.py index 4c7f0b55..948fc670 100755 --- a/mmgen/term.py +++ b/mmgen/term.py @@ -47,14 +47,7 @@ class MMGenTerm(object): @classmethod def register_cleanup(cls): - if gc.platform == 'linux' and not hasattr(cls,'cleanup_registered'): - import atexit - atexit.register( - lambda: termios.tcsetattr( - cls.stdin_fd, - termios.TCSADRAIN, - cls.orig_term) ) - cls.cleanup_registered = True + pass @classmethod def init(cls,noecho=False): @@ -74,6 +67,17 @@ class MMGenTerm(object): class MMGenTermLinux(MMGenTerm): + @classmethod + def register_cleanup(cls): + if not hasattr(cls,'cleanup_registered'): + import atexit + atexit.register( + lambda: termios.tcsetattr( + cls.stdin_fd, + termios.TCSADRAIN, + cls.orig_term) ) + cls.cleanup_registered = True + @classmethod def reset(cls): termios.tcsetattr( cls.stdin_fd, termios.TCSANOW, cls.orig_term ) @@ -159,6 +163,10 @@ class MMGenTermLinux(MMGenTerm): class MMGenTermLinuxStub(MMGenTermLinux): + @classmethod + def register_cleanup(cls): + pass + @classmethod def init(cls,noecho=False): cls.stdin_fd = sys.stdin.fileno()