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
This commit is contained in:
Vitaly Potyarkin
2023-04-28 10:09:56 +00:00
parent 87d82d3af0
commit 418593def3
3 changed files with 15 additions and 3 deletions

View File

@@ -1,3 +1,6 @@
//go:build go1.12
// +build go1.12
package pty
import (

View File

@@ -1,7 +1,6 @@
//go:build !windows
// +build !windows
//go:build !windows && go1.12
// +build !windows,go1.12
//
package pty
import "os"

10
ioctl_legacy.go Normal file
View File

@@ -0,0 +1,10 @@
//go:build !windows && !go1.12
// +build !windows,!go1.12
package pty
import "os"
func ioctl(f *os.File, cmd, ptr uintptr) error {
return ioctl_inner(f.Fd(), cmd, ptr) // fall back to blocking io (old behavior)
}