2018-02-05 19:52:44 -05:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package gottyclient
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
2018-03-24 07:18:46 -04:00
|
|
|
"golang.org/x/sys/unix"
|
2018-02-05 19:52:44 -05:00
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
func notifySignalSIGWINCH(c chan<- os.Signal) {
|
|
|
|
signal.Notify(c, syscall.SIGWINCH)
|
|
|
|
}
|
|
|
|
|
|
|
|
func resetSignalSIGWINCH() {
|
|
|
|
signal.Reset(syscall.SIGWINCH)
|
|
|
|
}
|
|
|
|
|
|
|
|
func syscallTIOCGWINSZ() ([]byte, error) {
|
2018-03-24 07:18:46 -04:00
|
|
|
ws, err := unix.IoctlGetWinsize(0, 0)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("ioctl error: %v", err)
|
|
|
|
}
|
2018-02-05 19:52:44 -05:00
|
|
|
b, err := json.Marshal(ws)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("json.Marshal error: %v", err)
|
|
|
|
}
|
|
|
|
return b, err
|
|
|
|
}
|