Skip to content

Commit ae64c17

Browse files
fix(flush_stdin): use deep copy for termios settings
The previous implementation used list(old) which creates a shallow copy. Since old[6] (the cc array) is itself a list, both old[6] and new[6] pointed to the same object. Modifying new[6][VMIN] and new[6][VTIME] also corrupted old[6], making the restore at the end ineffective. This fix uses a comprehension that copies nested lists, ensuring the original termios settings are preserved for proper restoration. Co-authored-by: openhands <openhands@all-hands.dev>
1 parent 012422c commit ae64c17

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

openhands-sdk/openhands/sdk/logger/logger.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ def flush_stdin() -> int:
239239
old = None
240240
try:
241241
old = termios.tcgetattr(_sys.stdin)
242-
new = list(old)
242+
# Deep copy required: old[6] is a list (cc), and list(old) only
243+
# does a shallow copy. Without deep copy, modifying new[6][VMIN]
244+
# would also modify old[6][VMIN], corrupting the restore.
245+
new = [item[:] if isinstance(item, list) else item for item in old]
243246
new[3] &= ~(termios.ICANON | termios.ECHO)
244247
new[6][termios.VMIN] = 0
245248
new[6][termios.VTIME] = 0

0 commit comments

Comments
 (0)