fix: preserve Unix PTY lifecycle and final output - #1930
Open
raphamorim wants to merge 8 commits into
Open
raphamorim wants to merge 8 commits into
raphamorim wants to merge 8 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #1927 (thanks @rawkode; the original commit is preserved) with six review fixes on top.
Review fixes over #1927
ErremitsChildExitedand callsterminal.exit(), so a reader failure no longer SIGKILLs the shell while leaving a live-looking pane whose keystrokes go into a dead channel.Ok(0)from the ConPTY ring means momentarily empty, not closed, so the post-exit drain retries it until the 100ms deadline instead of stopping at the first empty read. Unix EOF semantics are unchanged and the drain tests pass on both platforms.Route::quitwas a bareprocess::exit(0)that skipped every destructor; quit paths now exit the event loop soexitingdrops all routes.Context/Surfacedrops also deliver SIGHUP synchronously through a newChildTerminatorhandle that shares the lifecycle state, so a reaped PID is never signaled (the handle no-ops on contention rather than stalling the UI thread behind a running escalation).killpg(getpgid(pid))), like ghostty and kitty, reaching descendants and shrinking the PID-reuse window; it falls back tokill(pid)while the child still shares our own group.terminatewithTimedOutinstead of blocking the lifecycle mutex forever. Lifecycle statesHungUp/Killedensure exactly one SIGHUP per close (HUP traps run once) and make retries after a timed-out reap a brief re-poll instead of a repeated 2s escalation.killpgreports EPERM when any group member is unsignalable (setuid login(1) wrapper, sudo children) even though the signal reached the others; failing there would skip escalation and reaping and leak a zombie (see ghostty#2273).kill_pidexport and updated the libriochild_pid()doc, which told embedders to killpg the pid themselves on teardown and would now race the internal escalation.