Terminal: restore original termios on panic and terminating signals - #105
Conversation
Save original termios at startup and restore on panic / SIGTERM/SIGQUIT/SIGHUP. Fixes TruFoundation#94.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe shell now saves stdin terminal attributes at startup and restores them during panic handling and selected termination signals. Restoration uses synchronized global state and best-effort system calls. ChangesTerminal cleanup
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Shell
participant tty
participant Terminal
participant SignalOrPanic
Shell->>tty: save_original_termios
tty->>Terminal: tcgetattr
Terminal-->>tty: original attributes
SignalOrPanic->>tty: restore_original_termios
tty->>Terminal: tcsetattr
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)❌ Error creating Unit Test PR.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note Unit test generation is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Generating unit tests... This may take up to 20 minutes. |
|
❌ Failed to create PR with unit tests: AGENT_CHAT: Failed to open pull request |
Problem: when the shell panics or is killed while the terminal is in raw/cbreak mode, the terminal can be left unusable (no echo / broken input).
Fix: save the original termios at startup and restore it from a panic hook and for terminating signals (SIGTERM, SIGQUIT, SIGHUP).
Files changed: src/tty.rs (new), src/main.rs, src/job_control.rs.
This prevents users from needing to run reset or reopen the terminal after a crash. Closes #94
Summary by CodeRabbit
SIGTERM,SIGQUIT, andSIGHUP.