Files
creack.pty/ioctl.go
Vitaly Potyarkin 418593def3 Restore support for older Go versions
When compiled with go older than 1.12 creack/pty will not include a fix
for blocking Read() and will be prone to data races - but at least it will work

For more information see issues: #88 #114 #156 #162
2023-04-28 10:16:36 +00:00

24 lines
425 B
Go

//go:build !windows && go1.12
// +build !windows,go1.12
package pty
import "os"
func ioctl(f *os.File, cmd, ptr uintptr) error {
sc, e := f.SyscallConn()
if e != nil {
return ioctl_inner(f.Fd(), cmd, ptr) // fall back to blocking io (old behavior)
}
ch := make(chan error, 1)
defer close(ch)
e = sc.Control(func(fd uintptr) { ch <- ioctl_inner(fd, cmd, ptr) })
if e != nil {
return e
}
e = <-ch
return e
}