mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-13 20:14:12 +02:00
Function to drain controlling tty
This commit is contained in:
@@ -315,3 +315,25 @@ func DebugPrintln(a ...any) {
|
||||
term.DebugPrintln(a...)
|
||||
}
|
||||
}
|
||||
|
||||
func DrainControllingTTY(wait_for time.Duration) {
|
||||
tty, err := OpenControllingTerm(SetRaw, SetNoEcho)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
sel := utils.CreateSelect(1)
|
||||
sel.RegisterRead(tty.Fd())
|
||||
for {
|
||||
n, err := sel.Wait(wait_for)
|
||||
if err == unix.EINTR {
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if n > 0 && sel.IsReadyToRead(tty.Fd()) {
|
||||
tty.Read(make([]byte, 256))
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user