Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/strands_tools/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ def execute_with_pty(self, command: str, cwd: str, non_interactive_mode: bool) -
return exit_code, "".join(output), ""

finally:
# Close the PTY file descriptor
if "fd" in locals() and pid > 0:
try:
os.close(fd)
except OSError:
pass
# Restore terminal settings only if they were saved and changed.
if not non_interactive_mode and old_tty:
termios.tcsetattr(sys.stdin, termios.TCSAFLUSH, old_tty)
Expand Down