Skip to content

Commit

Permalink
Add pty.InheritSize for solaris support (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
whorfin committed May 29, 2021
1 parent 4f15fbd commit a76ea1c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions util_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ func Getsize(t *os.File) (rows, cols int, err error) {
}
}

// InheritSize applies the terminal size of pty to tty. This should be run
// in a signal handler for syscall.SIGWINCH to automatically resize the tty when
// the pty receives a window size change notification.
func InheritSize(pty, tty *os.File) error {
size, err := GetsizeFull(pty)
if err != nil {
return err
}
err = Setsize(tty, size)
if err != nil {
return err
}
return nil
}

// Setsize resizes t to s.
func Setsize(t *os.File, ws *Winsize) error {
wsz := unix.Winsize{ws.Rows, ws.Cols, ws.X, ws.Y}
Expand Down

0 comments on commit a76ea1c

Please sign in to comment.