Skip to content

Commit

Permalink
Make shutdown more reliable
Browse files Browse the repository at this point in the history
At least I hope it is...
  • Loading branch information
walles committed Jun 24, 2024
1 parent a964151 commit 83dffa6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions twin/screen.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@ func NewScreenWithMouseModeAndColorType(mouseMode MouseMode, terminalColorCount
// Close() restores terminal to normal state, must be called after you are done
// with the screen returned by NewScreen()
func (screen *UnixScreen) Close() {
// Tell the pager to exit unless it hasn't already
screen.events <- EventExit{}

// Tell our main loop to exit. It may still be stuck in a read() call after
// this, but even if it posts nore events the pager has already exited and
// nobody will care.
screen.ttyIn.Close()

screen.hideCursor(false)
screen.enableMouseTracking(false)
screen.setAlternateScreenMode(false)
Expand Down

0 comments on commit 83dffa6

Please sign in to comment.