Skip to content

fix(pty): don't stop relay on bare POLLHUP/POLLERR without POLLIN#54

Merged
kipz merged 1 commit into
developfrom
kipz/fix-pty-relay-fragility
Jun 24, 2026
Merged

fix(pty): don't stop relay on bare POLLHUP/POLLERR without POLLIN#54
kipz merged 1 commit into
developfrom
kipz/fix-pty-relay-fragility

Conversation

@kipz

@kipz kipz commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Problem

handle_pty_poll_events triggered proxy_master_to_client on any of POLLIN|POLLHUP|POLLERR|POLLNVAL. When POLLHUP or POLLERR fired without POLLIN — which happens transiently during interactive TUI startup (e.g. Node.js reinitialising its TTY at Claude Code launch) — read() returned EIO. proxy_master_to_client_once maps any read error to MasterProxyOutcome::Closed, causing the relay loop to stop while the child process was still alive. The startup-timeout safety net is disabled for interactive TUIs, so nothing recovered the relay → indefinite hang.

Reported in: DataDog/shadowfax#421

Fix

Only relay data (and stop on Closed/EOF) when POLLIN is set. Bare POLLHUP/POLLERR/POLLNVAL without POLLIN are now ignored in handle_pty_poll_events; the waitpid path in the caller detects child exit instead of relying on PTY master HUP.

handle_pty_poll_events previously triggered proxy_master_to_client on
any combination of POLLIN|POLLHUP|POLLERR|POLLNVAL. When POLLHUP or
POLLERR fired without POLLIN (e.g. transiently during Node.js TTY
reinitialisation at Claude Code startup), read() returned EIO, which
proxy_master_to_client mapped to Closed, tearing down the relay while
the child was still alive. For interactive TUIs the startup-timeout
safety net is disabled, so nothing recovered the relay — causing an
indefinite hang.

Fix: only relay data (and stop on Closed/EOF) when POLLIN is set.
Bare POLLHUP/POLLERR/POLLNVAL without POLLIN are now ignored; the
waitpid path in the caller detects child exit instead.
@github-actions github-actions Bot added the bug Something isn't working label Jun 19, 2026
@kipz kipz marked this pull request as ready for review June 24, 2026 08:18
@kipz kipz merged commit 9f9c662 into develop Jun 24, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant