Skip to content

Commit

Permalink
Avoid modifying saved terminal state
Browse files Browse the repository at this point in the history
Fixes: c-bata#228
  • Loading branch information
elyscape committed Aug 23, 2022
1 parent 82a9122 commit 7fe657d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/term/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ func SetRaw(fd int) error {
n.Cc[syscall.VMIN] = 1
n.Cc[syscall.VTIME] = 0

return termios.Tcsetattr(uintptr(fd), termios.TCSANOW, (*unix.Termios)(n))
return termios.Tcsetattr(uintptr(fd), termios.TCSANOW, (*unix.Termios)(&n))
}
6 changes: 3 additions & 3 deletions internal/term/term.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ var (
saveTermiosOnce sync.Once
)

func getOriginalTermios(fd int) (*unix.Termios, error) {
func getOriginalTermios(fd int) (unix.Termios, error) {
var err error
saveTermiosOnce.Do(func() {
saveTermiosFD = fd
saveTermios, err = termios.Tcgetattr(uintptr(fd))
})
return saveTermios, err
return *saveTermios, err
}

// Restore terminal's mode.
Expand All @@ -30,5 +30,5 @@ func Restore() error {
if err != nil {
return err
}
return termios.Tcsetattr(uintptr(saveTermiosFD), termios.TCSANOW, o)
return termios.Tcsetattr(uintptr(saveTermiosFD), termios.TCSANOW, &o)
}

0 comments on commit 7fe657d

Please sign in to comment.