From f0295a7ca31c0f78c76b19ed80ab4ec43fd49478 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Tue, 2 Apr 2019 10:15:29 +0200 Subject: [PATCH] fix tty to avoid panic after resizing term near exit time --- go.mod | 2 +- go.sum | 4 ++-- vendor/github.com/mattn/go-tty/tty_unix.go | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index d713f22fe..bb8a45896 100644 --- a/go.mod +++ b/go.mod @@ -106,7 +106,7 @@ require ( github.com/masterzen/azure-sdk-for-go v0.0.0-20161014135628-ee4f0065d00c // indirect github.com/masterzen/simplexml v0.0.0-20140219194429-95ba30457eb1 // indirect github.com/masterzen/winrm v0.0.0-20180224160350-7e40f93ae939 - github.com/mattn/go-tty v0.0.0-20190322114730-5518497423d1 + github.com/mattn/go-tty v0.0.0-20190402035014-76a2065f1a95 github.com/miekg/dns v1.1.1 // indirect github.com/mitchellh/cli v0.0.0-20170908181043-65fcae5817c8 github.com/mitchellh/copystructure v1.0.0 // indirect diff --git a/go.sum b/go.sum index dd55fe0a6..21204b7dd 100644 --- a/go.sum +++ b/go.sum @@ -285,8 +285,8 @@ github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-tty v0.0.0-20190322114730-5518497423d1 h1:VRq8MIkqXRI9aytxCxOTDiQorwXRt8vlSOapwx8Ubys= -github.com/mattn/go-tty v0.0.0-20190322114730-5518497423d1/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE= +github.com/mattn/go-tty v0.0.0-20190402035014-76a2065f1a95 h1:zyW7ieMaS0tXk1KgXxFgQ+HAMmxYpwe7MiAzE4C/rkE= +github.com/mattn/go-tty v0.0.0-20190402035014-76a2065f1a95/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= diff --git a/vendor/github.com/mattn/go-tty/tty_unix.go b/vendor/github.com/mattn/go-tty/tty_unix.go index 579df5c2e..2a4350cca 100644 --- a/vendor/github.com/mattn/go-tty/tty_unix.go +++ b/vendor/github.com/mattn/go-tty/tty_unix.go @@ -52,6 +52,7 @@ func open() (*TTY, error) { tty.ss = make(chan os.Signal, 1) signal.Notify(tty.ss, syscall.SIGWINCH) go func() { + defer close(tty.ws) for sig := range tty.ss { switch sig { case syscall.SIGWINCH: @@ -78,8 +79,8 @@ func (tty *TTY) readRune() (rune, error) { } func (tty *TTY) close() error { + signal.Stop(tty.ss) close(tty.ss) - close(tty.ws) _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(tty.in.Fd()), ioctlWriteTermios, uintptr(unsafe.Pointer(&tty.termios)), 0, 0, 0) return err }