🔴 [H8] 初始文件加载失败 → 终端状态损坏 #8

Closed
opened 2026-06-03 13:52:51 +08:00 by dailz · 1 comment
Owner

文件: tui/main.rs:17-30
分类: 终端安全

问题: 先启用 raw mode + alternate screen,再加载文件。加载失败时调用 process::exit(1)绕过所有终端恢复逻辑,导致用户 shell 不可用。

crossterm::terminal::enable_raw_mode()?;
crossterm::execute!(stdout, EnterAlternateScreen)?;
// ...
std::process::exit(1);  // ← 跳过 disable_raw_mode!

建议修复: 使用 RAII guard(TerminalGuard),Drop 时恢复终端;文件加载移到终端初始化之前。

**文件**: `tui/main.rs:17-30` **分类**: 终端安全 **问题**: 先启用 raw mode + alternate screen,再加载文件。加载失败时调用 `process::exit(1)`,**绕过所有终端恢复逻辑**,导致用户 shell 不可用。 ```rust crossterm::terminal::enable_raw_mode()?; crossterm::execute!(stdout, EnterAlternateScreen)?; // ... std::process::exit(1); // ← 跳过 disable_raw_mode! ``` **建议修复**: 使用 RAII guard(`TerminalGuard`),`Drop` 时恢复终端;文件加载移到终端初始化之前。
dailz added the area/tuibugseverity/high labels 2026-06-03 13:52:51 +08:00
dailz closed this issue 2026-06-04 16:11:24 +08:00
Author
Owner

Fixed in b7938e0. RAII TerminalGuard with Drop cleanup. 88 tests pass. tmux integration test verified terminal restored on error exit (exit code 1) and normal exit (exit code 0).

Fixed in b7938e0. RAII TerminalGuard with Drop cleanup. 88 tests pass. tmux integration test verified terminal restored on error exit (exit code 1) and normal exit (exit code 0).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dailz/logViewer#8