github.com/insolar/x-crypto@v0.0.0-20191031140942-75fab8a325f6/rand/internal/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 // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 7 package unix 8 9 import ( 10 "syscall" 11 _ "unsafe" // for go:linkname 12 ) 13 14 //go:linkname syscall_fcntl syscall.fcntl 15 func syscall_fcntl(fd int, cmd int, arg int) (val int, err error) 16 17 func IsNonblock(fd int) (nonblocking bool, err error) { 18 flag, err := syscall_fcntl(fd, syscall.F_GETFL, 0) 19 if err != nil { 20 return false, err 21 } 22 return flag&syscall.O_NONBLOCK != 0, nil 23 }