Files
wazero/internal/sysfs/nonblock_windows.go
Crypt Keeper 66070781b1 Supports compilation with GOOS=plan9 (#1603)
Signed-off-by: Adrian Cole <adrian@tetrate.io>
2023-07-31 06:47:23 +08:00

25 lines
603 B
Go

package sysfs
import (
"io/fs"
"syscall"
"github.com/tetratelabs/wazero/experimental/sys"
"github.com/tetratelabs/wazero/internal/fsapi"
)
func setNonblock(fd uintptr, enable bool) sys.Errno {
// We invoke the syscall, but this is currently no-op.
return sys.UnwrapOSError(syscall.SetNonblock(syscall.Handle(fd), enable))
}
func isNonblock(f *osFile) bool {
// On Windows, we support non-blocking reads only on named pipes.
isValid := false
st, errno := f.Stat()
if errno == 0 {
isValid = st.Mode&fs.ModeNamedPipe != 0
}
return isValid && f.flag&fsapi.O_NONBLOCK == fsapi.O_NONBLOCK
}