aboutsummaryrefslogtreecommitdiff
path: root/src/os
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2020-09-15 13:49:45 +0200
committerTobias Klauser <tobias.klauser@gmail.com>2020-09-16 08:49:14 +0000
commite82c9bd81654dab14f786c26af2dd8ea3a7a1737 (patch)
tree02b2b4f88a1154e59c3f39a35bb3a52edbf92590 /src/os
parent790fa1c546a05936406f6bbf24f6a6ddeb6ec6ad (diff)
downloadgo-e82c9bd81654dab14f786c26af2dd8ea3a7a1737.tar.gz
go-e82c9bd81654dab14f786c26af2dd8ea3a7a1737.zip
os, internal/syscall/unix: use pipe2 instead of pipe on illumos
Illumos provides the pipe2 syscall. Add a wrapper to internal/syscall/unix and use it to implement os.Pipe. Change-Id: I26ecdbcae1e8d51f80e2bc8a86fb129826387b1f Reviewed-on: https://go-review.googlesource.com/c/go/+/254981 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/os')
-rw-r--r--src/os/pipe2_illumos.go25
-rw-r--r--src/os/pipe_bsd.go2
2 files changed, 26 insertions, 1 deletions
diff --git a/src/os/pipe2_illumos.go b/src/os/pipe2_illumos.go
new file mode 100644
index 0000000000..026ce62b9a
--- /dev/null
+++ b/src/os/pipe2_illumos.go
@@ -0,0 +1,25 @@
+// Copyright 2020 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 illumos
+
+package os
+
+import (
+ "internal/syscall/unix"
+ "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
+
+ e := unix.Pipe2(p[0:], syscall.O_CLOEXEC)
+ if e != nil {
+ return nil, nil, NewSyscallError("pipe", e)
+ }
+
+ return newFile(uintptr(p[0]), "|0", kindPipe), newFile(uintptr(p[1]), "|1", kindPipe), nil
+}
diff --git a/src/os/pipe_bsd.go b/src/os/pipe_bsd.go
index 0d2d82feb9..115d6baa19 100644
--- a/src/os/pipe_bsd.go
+++ b/src/os/pipe_bsd.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build aix darwin dragonfly js,wasm solaris
+// +build aix darwin dragonfly js,wasm solaris,!illumos
package os