Repository navigation
fix: end the editor and manager panes when the terminal hangs up - #90
Open
backnotprop wants to merge 1 commit into
Open
backnotprop wants to merge 1 commit into
backnotprop wants to merge 1 commit into
Conversation
crossterm's unix reader never returns once its tty hangs up (read gives Ok(0) forever, crossterm-rs/crossterm#793), so the panes never checked the SIGTERM/SIGHUP flag again and spun at 100% CPU. A watch thread now exits with status 129 when the terminal reports POLLHUP, and with 128+signal when a signal is still pending 500 ms after it arrived. Fixes plannotator/plannotator-tui#128
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.
Refs plannotator/plannotator-tui#128 (the plannotator-tui half is plannotator/plannotator-tui#139). After the pane's terminal closes, the
editor(andmanager) process stays behind, adopted by launchd, at about 100% CPU, and SIGTERM does nothing.Terminationsets a flag on SIGTERM/SIGHUP, and the pane loops check it betweenevent::pollcalls. After a hang-up, crossterm's unix reader never returns:readgivesOk(0)forever and it only leaves its read loop onWouldBlock(crossterm-rs/crossterm#793, still open). So the loop never checks the flag again. This happens even when SIGHUP is delivered normally, because our handler replaces the default action.Termination::installnow also starts a watch thread (unix only) that wakes every 500 ms:POLLHUP, it callsratatui::try_restoreand exits with 129. It watches stdin, or stdout if stdin is not a terminal. A finished pipe reportsPOLLHUPtoo, so a pipe is never watched.tcgetattr/isattycannot detect this: on macOS both keep succeeding on a hung-up pty.AtomicUsizethat holds the signal number (register_usize).requested()is unchanged for callers.This only adds the
event,stdioandtermiosfeatures to the existing unixrustixdependency (ptyfor tests).Cargo.lockis unchanged.Evidence
macOS, private tmux server,
tmux kill-server:editor, SIGHUP deliverededitor,trap '' HUPmanagereditorwith the tty watch disabled (local experiment only, not in this diff)Esc in the editor and
qin the manager still give 0, and SIGTERM on a live pane still takes the normal path (0, under 0.1 s).Tests
termination::testsuses a real pty. It reads as hung up only after its controller is dropped, and a finished pipe on stdin is skipped for the terminal.cargo fmt --check,cargo clippy --all-targets -- -D warnings,cargo test --all-targets(124 + 12) pass. On Windows the watch code iscfg(unix).cargo clippy --target x86_64-pc-windows-msvc --all-targets -- -D warningspasses locally, and CI'scheck-windowsbuilds it for real.Shipping this needs a helper release (
rust-lite-v0.2.4) and a plugin pin bump, as for 0.2.3.