github.com/fisco-bcos/crypto@v0.0.0-20200202032121-bd8ab0b5d4f1/internal/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  // +build aix dragonfly freebsd linux netbsd openbsd solaris
     6  
     7  package unix
     8  
     9  import "syscall"
    10  
    11  func IsNonblock(fd int) (nonblocking bool, err error) {
    12  	flag, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), uintptr(syscall.F_GETFL), 0)
    13  	if e1 != 0 {
    14  		return false, e1
    15  	}
    16  	return flag&syscall.O_NONBLOCK != 0, nil
    17  }