diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-01-31 19:51:45 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2021-03-01 09:17:40 +0000 |
commit | 2a8df4488ee893353b1200794bde758e9726e7c7 (patch) | |
tree | 8e577092035ec0bdbc38d47fee7a3757be7f0600 /src/os/exec/exec_test.go | |
parent | 5ff7ec98b7727b3641df25200345b1aa50b6ff35 (diff) | |
download | go-2a8df4488ee893353b1200794bde758e9726e7c7.tar.gz go-2a8df4488ee893353b1200794bde758e9726e7c7.zip |
os: mark pipes returned by os.Pipe() as inheritable by default
Now that we don't automatically pass all inheritable handles to new
processes, we can make pipes returned by os.Pipe() inheritable, just
like they are on Unix. This then allows them to be passed through the
SysProcAttr.AdditionalInheritedHandles parameter simply.
Updates #44011.
Fixes #21085.
Change-Id: I8eae329fbc74f9dc7962136fa9aae8fb66879751
Reviewed-on: https://go-review.googlesource.com/c/go/+/288299
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Diffstat (limited to 'src/os/exec/exec_test.go')
-rw-r--r-- | src/os/exec/exec_test.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index 8b0c93f382..57591a38ab 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -915,6 +915,16 @@ func TestHelperProcess(*testing.T) { case "sleep": time.Sleep(3 * time.Second) os.Exit(0) + case "pipehandle": + handle, _ := strconv.ParseUint(args[0], 16, 64) + pipe := os.NewFile(uintptr(handle), "") + _, err := fmt.Fprint(pipe, args[1]) + if err != nil { + fmt.Fprintf(os.Stderr, "writing to pipe failed: %v\n", err) + os.Exit(1) + } + pipe.Close() + os.Exit(0) default: fmt.Fprintf(os.Stderr, "Unknown command %q\n", cmd) os.Exit(2) |