diff --git a/src/strands_tools/shell.py b/src/strands_tools/shell.py index f45fced4..61fe00f0 100644 --- a/src/strands_tools/shell.py +++ b/src/strands_tools/shell.py @@ -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)