-
-
Notifications
You must be signed in to change notification settings - Fork 217
Description
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:
-
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
-
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, butInteractiveContinuePrinterwas 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 callscon.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.