Skip to content

Commit e701458

Browse files
committed
Drain input when finalizing screen on Unix systems
1 parent 1482264 commit e701458

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tscreen_unix.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"os/signal"
2222
"strconv"
2323
"syscall"
24+
"time"
2425

2526
"golang.org/x/sys/unix"
2627
"golang.org/x/term"
@@ -66,10 +67,15 @@ func (t *tScreen) termioFini() {
6667

6768
signal.Stop(t.sigwinch)
6869

70+
fd := int(t.out.(*os.File).Fd())
71+
72+
_ = t.in.(*os.File).SetReadDeadline(time.Now())
73+
_ = tcSetBufParams(fd, 0, 0)
74+
6975
<-t.indoneq
7076

7177
if t.out != nil && t.saved != nil {
72-
term.Restore(int(t.out.(*os.File).Fd()), t.saved)
78+
term.Restore(fd, t.saved)
7379
t.out.(*os.File).Close()
7480
}
7581

0 commit comments

Comments
 (0)