From 85678013bedad42ea5bd46be6f9e5cd06f5b3c70 Mon Sep 17 00:00:00 2001 From: petereon Date: Wed, 7 Dec 2022 18:00:27 +0100 Subject: [PATCH] fix: resetting file control to blocking on sysin file descriptor --- yakh/_yakh.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/yakh/_yakh.py b/yakh/_yakh.py index 8a8e165..a0772e5 100644 --- a/yakh/_yakh.py +++ b/yakh/_yakh.py @@ -30,9 +30,9 @@ def __break_on_char(imput_str: str) -> List[str]: def __get_key() -> str: fd_input = sys.stdin.fileno() + term_attr = termios.tcgetattr(fd_input) fl = fcntl.fcntl(fd_input, fcntl.F_GETFL) fcntl.fcntl(fd_input, fcntl.F_SETFL, fl | os.O_NONBLOCK) - term_attr = termios.tcgetattr(fd_input) tty.setraw(fd_input) ch_str = "" try: @@ -48,6 +48,7 @@ def __get_key() -> str: pass finally: termios.tcsetattr(fd_input, termios.TCSADRAIN, term_attr) + fcntl.fcntl(fd_input, fcntl.F_SETFL, fl) first, *rest = __break_on_char(ch_str) __unconsumed_chars.extend(rest) return first