Closed azr closed 5 years ago
I don't understand what you want to fix (as far as I can see your change of code)
Hey @mattn, the main issue is that go-tty tries to send a WINSIZE on a chan that is never read upon and with blocking sends. When you leave the program, go panics.
here's a sample crashing code, just start it and resize the windows.
package main
import (
"log"
"github.com/mattn/go-tty"
)
func main() {
tty, err := tty.Open()
if err != nil {
log.Fatal(err)
}
log.Print("now, resize the windows, type things and leave:")
str, err := tty.ReadString()
log.Printf("str: %s, err: %v", str, err)
tty.Close()
}
I could repro on windows and mac ( unix ).
On unix I just fixed it by making sure the chans are close in order.
On windows by just using non blocking sends.
Like the golang signal pkg does.
I prefer to use context.Context instead of closeC.
Looks good to me. Thank you.
if the term is resized when
ReadString
is being called and no one is reading form ws, we get apanic: send on closed channel
.It could make sense to poll getconsolescreenbufferinfo calls instead of this:
something started from the
sigwinch()
func