github.com/freddyisaac/sicortex-golang@v0.0.0-20231019035217-e03519e66f60/src/os/pipe_linux.go (about) 1 // Copyright 2013 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 package os 6 7 import "syscall" 8 9 // Pipe returns a connected pair of Files; reads from r return bytes written to w. 10 // It returns the files and an error, if any. 11 func Pipe() (r *File, w *File, err error) { 12 var p [2]int 13 14 /* 15 e := syscall.Pipe2(p[0:], syscall.O_CLOEXEC) 16 // pipe2 was added in 2.6.27 and our minimum requirement is 2.6.23, so it 17 // might not be implemented. 18 if e == syscall.ENOSYS { 19 */ 20 // See ../syscall/exec.go for description of lock. 21 syscall.ForkLock.RLock() 22 e := syscall.Pipe(p[0:]) 23 if e != nil { 24 syscall.ForkLock.RUnlock() 25 return nil, nil, NewSyscallError("pipe", e) 26 } 27 syscall.CloseOnExec(p[0]) 28 syscall.CloseOnExec(p[1]) 29 syscall.ForkLock.RUnlock() 30 /* 31 } else if e != nil { 32 return nil, nil, NewSyscallError("pipe2", e) 33 } 34 */ 35 36 f1 := NewFile(uintptr(p[0]), "|0") 37 f2 := NewFile(uintptr(p[1]), "|1") 38 return f1, f2, nil 39 40 // return NewFile(uintptr(p[0]), "|0"), NewFile(uintptr(p[1]), "|1"), nil 41 }