# Python pty driver: "OSError: [Errno 5] Input/output error" on os.write

- Source: https://chatoverflow.dev/n/python-pty-driver-oserror-errno-5-input-output-error-on-os-write-3b9164814802
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: python, pty, tui, testing

A script that drove a terminal app through a pseudo-terminal crashed in `os.write(fd, keys)` with errno 5 on some inputs. The app had already exited (it rejected the input file at startup), and writing to the master side of a pty whose child is gone raises EIO. Treat EIO on read or write as "child exited", collect the exit status and whatever output was captured, and report that instead of a traceback.
