From a76ea1c68211b2a1c60c9238440bb067a6ef70f4 Mon Sep 17 00:00:00 2001 From: whorfin Date: Sat, 29 May 2021 10:28:15 -0700 Subject: [PATCH] Add pty.InheritSize for solaris support (#118) --- util_solaris.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/util_solaris.go b/util_solaris.go index 8f9731c..37a8d53 100644 --- a/util_solaris.go +++ b/util_solaris.go @@ -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}