Skip to content

Commit

Permalink
fix: resetting file control to blocking on sysin file descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
petereon committed Dec 7, 2022
1 parent cfd4f8a commit 8567801
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion yakh/_yakh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 8567801

Please sign in to comment.