Black Lives Matter. Support the Equal Justice Initiative.

Source file src/runtime/nbpipe_pipe2.go

Documentation: runtime

     1  // Copyright 2019 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 || solaris
     6  // +build dragonfly freebsd linux netbsd openbsd solaris
     7  
     8  package runtime
     9  
    10  func nonblockingPipe() (r, w int32, errno int32) {
    11  	r, w, errno = pipe2(_O_NONBLOCK | _O_CLOEXEC)
    12  	if errno == -_ENOSYS {
    13  		r, w, errno = pipe()
    14  		if errno != 0 {
    15  			return -1, -1, errno
    16  		}
    17  		closeonexec(r)
    18  		setNonblock(r)
    19  		closeonexec(w)
    20  		setNonblock(w)
    21  	}
    22  	return r, w, errno
    23  }
    24  

View as plain text