github.com/elijahmorg/goternal@v1.18.0/syscall/unix/nonblocking.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build dragonfly || freebsd || linux || netbsd || openbsd 6 7 package unix 8 9 import "syscall" 10 11 // FcntlSyscall is the number for the fcntl system call. This is 12 // usually SYS_FCNTL, but can be overridden to SYS_FCNTL64. 13 var FcntlSyscall uintptr = syscall.SYS_FCNTL 14 15 func IsNonblock(fd int) (nonblocking bool, err error) { 16 flag, _, e1 := syscall.Syscall(FcntlSyscall, uintptr(fd), uintptr(syscall.F_GETFL), 0) 17 if e1 != 0 { 18 return false, e1 19 } 20 return flag&syscall.O_NONBLOCK != 0, nil 21 }