Skip to content

fix(pty): log the cause when the PTY reader thread terminates#49

Open
roramirez wants to merge 1 commit into
mainfrom
hardening/04-pty-read-log
Open

fix(pty): log the cause when the PTY reader thread terminates#49
roramirez wants to merge 1 commit into
mainfrom
hardening/04-pty-read-log

Conversation

@roramirez

@roramirez roramirez commented Jun 30, 2026

Copy link
Copy Markdown
Owner

What

The PTY reader thread collapsed a clean EOF and a genuine I/O error into a single Ok(0) | Err(_) => break, discarding the disconnection cause and making it invisible under RUST_LOG.

Changes

  • Extract a pure classify_read function that keeps EOF, error, and data as distinct variants.
  • pty_reader_loop logs the reason for every termination (EOF, read error, closed output channel) at debug level.

Tests

  • classify_read distinguishes the three cases (regression: the distinction did not exist before).
  • Integration test: the reader thread terminates on PTY EOF instead of hanging.

Card

plan-todo/04-hardening-pty-read-errores.md

The reader loop collapsed clean EOF and genuine I/O errors into a single
`Ok(0) | Err(_) => break` arm, discarding the disconnection cause and
making it invisible under `RUST_LOG`. Extract a pure `classify_read` that
keeps EOF, error, and data as distinct outcomes, and a `pty_reader_loop`
that logs the reason for every termination (EOF, read error, or closed
output channel) at debug level.

Add a regression test asserting `classify_read` distinguishes the three
cases, plus an integration test that the reader thread terminates on PTY
EOF instead of hanging.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant