Skip to content

InteractiveContinuePrinter doesn't cleanup on Ctrl+C, leaving terminal in raw mode #758

@pcfreak30

Description

@pcfreak30

Pressing Ctrl+C during the setup wizard leaves the terminal in a broken state - the prompt text remains visible, bash history doesn't render properly (though it works), and typing renders fine. The terminal must be manually killed or reset to recover.

Root Cause: Two bugs in PTerm's InteractiveContinuePrinter:

  1. PTerm calls os.Exit(1) directly in the keyboard callback, which:

    • Skips all deferred cleanup functions
    • Leaves the terminal in raw mode
    • When the shell inherits the terminal, it's broken
  2. PTerm never applied the fix from PR fix: make sure the interactive printers can cleanup after Ctrl+C #383 - The other interactive printers (InteractiveSelectPrinter, InteractiveMultiselectPrinter, InteractiveTextInputPrinter) were fixed in 2022 using a cancellation signal pattern that ensures cleanup runs before exit, but InteractiveContinuePrinter was left out.

Current required workaround: Created a copy of PTerm's InteractiveContinuePrinter that returns an error instead of calling os.Exit(1). This ensures:

  • The keyboard library's stopListener() is called (which calls con.Reset())
  • Terminal is properly restored to cooked mode
  • Error propagates up to let the caller handle Ctrl+C gracefully

Ideally would like to see more control over prompts so the caller can decide how to handle things vs hard setting ExitFunc in internal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions