diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-01-29 20:52:43 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-01-29 20:52:43 +0000 |
commit | d6f2922e91928b5191a5c5f1b3a6b320712b5ce3 (patch) | |
tree | 4f2fad1f4b778519bdd5941185c7e1d032af055b /libgo/go/os/pipe_bsd.go | |
parent | 91bfca59095b1cca9d4364996866848eaaf76c26 (diff) | |
download | gcc-d6f2922e91928b5191a5c5f1b3a6b320712b5ce3.zip gcc-d6f2922e91928b5191a5c5f1b3a6b320712b5ce3.tar.gz gcc-d6f2922e91928b5191a5c5f1b3a6b320712b5ce3.tar.bz2 |
libgo: Update Go library to master revision 15489/921e53d4863c.
From-SVN: r195560
Diffstat (limited to 'libgo/go/os/pipe_bsd.go')
-rw-r--r-- | libgo/go/os/pipe_bsd.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libgo/go/os/pipe_bsd.go b/libgo/go/os/pipe_bsd.go new file mode 100644 index 0000000..a2ce9a3 --- /dev/null +++ b/libgo/go/os/pipe_bsd.go @@ -0,0 +1,28 @@ +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin freebsd netbsd openbsd + +package os + +import "syscall" + +// Pipe returns a connected pair of Files; reads from r return bytes written to w. +// It returns the files and an error, if any. +func Pipe() (r *File, w *File, err error) { + var p [2]int + + // See ../syscall/exec.go for description of lock. + syscall.ForkLock.RLock() + e := syscall.Pipe(p[0:]) + if e != nil { + syscall.ForkLock.RUnlock() + return nil, nil, NewSyscallError("pipe", e) + } + syscall.CloseOnExec(p[0]) + syscall.CloseOnExec(p[1]) + syscall.ForkLock.RUnlock() + + return NewFile(uintptr(p[0]), "|0"), NewFile(uintptr(p[1]), "|1"), nil +} |