From 2ad9707c38618c2cfe1790d1cddcf93b947641fb Mon Sep 17 00:00:00 2001 From: Binit Shah Date: Wed, 19 Jan 2022 17:41:31 -0800 Subject: [PATCH] Fix hang on killing keyboard_teleop --- stretch_core/nodes/keyboard.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stretch_core/nodes/keyboard.py b/stretch_core/nodes/keyboard.py index 5d8c050..a9e7a8d 100644 --- a/stretch_core/nodes/keyboard.py +++ b/stretch_core/nodes/keyboard.py @@ -15,9 +15,13 @@ def getch(): # fd, as follows: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]" # from https://docs.python.org/2/library/termios.html original_tty_attributes = termios.tcgetattr(stdin_fd) - new_tty_attributes = original_tty_attributes[:] + new_tty_attributes = termios.tcgetattr(stdin_fd) # Change the lflag (local modes) to turn off canonical mode new_tty_attributes[3] &= ~termios.ICANON + # Set VMIN = 0 and VTIME > 0 for a timed read, as explained in: + # http://unixwiz.net/techtips/termios-vmin-vtime.html + new_tty_attributes[6][termios.VMIN] = b'\x00' + new_tty_attributes[6][termios.VTIME] = b'\x01' try: termios.tcsetattr(stdin_fd, termios.TCSAFLUSH, new_tty_attributes) ch1 = sys.stdin.read(1)