mirror of
https://github.com/creack/pty.git
synced 2026-04-01 11:07:11 +09:00
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
24 lines
425 B
Go
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
|
|
}
|