Skip to content

macOS: keep reading after a wrapped command revokes and reopens its terminal - #252

Merged
inxbit merged 3 commits into
mainfrom
fix/revoke-transient-eof
Dec 4, 2026
Merged

inxbit merged 3 commits into
mainfrom
fix/revoke-transient-eof

Conversation

@inxbit

@inxbit inxbit commented Dec 4, 2026

Copy link
Copy Markdown
Owner

What was wrong

macOS only. When a wrapped command revoked its terminal (revoke(2), as a getty or a login program does), reopened the same terminal and kept writing, PrismTTY read one zero-byte read from the PTY master, took it for the end and stopped drawing. Everything the command wrote afterwards was lost: 0 of 10 runs showed the later lines on 1.6.8.

What changes

  • On macOS a zero-byte read of the master is provisional while the command's exit has not been reported. PrismTTY waits up to 20 milliseconds on the existing child-exit notice and reads again; the exit report (or a closed notice) makes the end final.
  • The highlighting stream stays the same across the gap. A held partial line is still drawn after the usual 250 millisecond quiet holdback, once per quiet episode.
  • Linux is unchanged: it keeps the existing reader.

Measured (macOS, Apple silicon, revoke really executed)

1.6.8 this branch
lines written after revoke and reopen 0 of 10 runs 10 of 10 runs
lines written after close and reopen 10 of 10 10 of 10
partial line before a revoke, command stays alive drawn at the false end drawn after 0.25 s, same as a quiet terminal that was not revoked
revoke without reopen, 3 s 0.010 s user CPU 0.004 to 0.008 s user CPU (no busy loop)
SIGTERM to PrismTTY in that state 143 after 28 ms 143 after 30 ms
ordinary end of a command 0.92 ms median 0.89 and 1.12 ms median in two runs, bytes identical
prompt and typed echo after the reopen within 20 ms

Limits

  • After a revoke, a typed Ctrl-C may not signal the command (README); ending signals sent to PrismTTY work as before.
  • If the exit notice could not be set up, or a traced stop closes it, PrismTTY falls back to the old behavior for that session.

Tests

Three integration tests (revoke and reopen, close and reopen, held tail while revoked) and four unit tests of the reader. The two revoke tests fail, not skip, if the system refuses revoke(2). macOS: fmt and clippy clean, 1348 Rust tests and the node tests pass, privacy scan clean. Linux lints checked by cross-compiling.

@inxbit
inxbit marked this pull request as ready for review December 4, 2026 22:49
@inxbit
inxbit merged commit 41a7dd1 into main Dec 4, 2026
6 checks passed
@inxbit
inxbit deleted the fix/revoke-transient-eof branch December 4, 2026 22:50
@inxbit inxbit mentioned this pull request Dec 4, 2026
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