Skip to content

fix: Console mode not restored on crash — terminal left in raw mode #17

@martymcenroe

Description

@martymcenroe

Problem

Console mode changes apply to the current Python process. If unleashed crashes (segfault in ctypes, pywinpty panic), the console is left in raw mode. User terminal behaves weirdly: no echo, no line editing.

There's a try/finally to restore, but it won't work if Python segfaults.

Impact

Terminal is unusable until manually reset (reset or new terminal).

Recommendation

  1. Register an atexit handler as backup
  2. Consider writing original console mode to a temp file so a recovery script can restore it
  3. Add a --reset-terminal flag that just restores console mode and exits

Source

Deep audit (2026-02-12).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions