Restore terminal state on exit by properly closing TTY#4
Open
rafabmr wants to merge 2 commits intoyarlson:mainfrom
Open
Restore terminal state on exit by properly closing TTY#4rafabmr wants to merge 2 commits intoyarlson:mainfrom
rafabmr wants to merge 2 commits intoyarlson:mainfrom
Conversation
Fixes an issue where the terminal remained in raw mode after program exit, leaving input invisible. The TTY was not being properly closed, so echo stayed disabled. This change adds a Close() method to the Terminal struct and ensures it is always called with defer to correctly restore the terminal state.
|
I think I am running into this issue as well on arch Linux. When I ctrl+c out of the program, my terminal doesn't behave as expected after the fact and I find myself having to create an entirely new terminal session. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Once the program finishes running, the terminal doesn’t return to its normal behavior. Although keystrokes are still being captured internally, nothing is shown on screen. The cursor keeps blinking, but the characters the user types are invisible, making it feel like the terminal is “broken”.
Root Cause:
The terminal is opened in raw mode by go-tty but is never properly closed, leaving the terminal with echo disabled.
Expected Behavior:
Terminal state should be restored to normal after the program exits, allowing users to see their input.
Solution:
Description:
syscall.SIGWINCH is not available on Windows, causing build/runtime failures when compiling for the Windows platform.
Solution:
Add platform-specific handling or conditional compilation to avoid using syscall.SIGWINCH on Windows.