github.com/bir3/gocompiler@v0.3.205/src/internal/syscall/unix/nonblocking_libc.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 aix || darwin || (openbsd && !mips64) || solaris 6 7 package unix 8 9 import ( 10 "syscall" 11 _ "unsafe" // for go:linkname 12 ) 13 14 func IsNonblock(fd int) (nonblocking bool, err error) { 15 flag, e1 := fcntl(fd, syscall.F_GETFL, 0) 16 if e1 != nil { 17 return false, e1 18 } 19 return flag&syscall.O_NONBLOCK != 0, nil 20 } 21 22 func HasNonblockFlag(flag int) bool { 23 return flag&syscall.O_NONBLOCK != 0 24 } 25 26 // Implemented in the syscall package. 27 // 28 //go:linkname fcntl syscall.fcntl 29 func fcntl(fd int, cmd int, arg int) (int, error)