diff options
| author | Bryan Mills <bcmills@google.com> | 2022-10-04 19:55:56 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-10-04 21:17:23 +0000 |
| commit | 3380ee2520165187c3d1476c46d16bc76376d4d4 (patch) | |
| tree | a9a12b8168852dfbc397ddbf0a0ae8b9ae36680a /src/os/exec | |
| parent | 058f019e45fc1f18842e0339d7d56d804936263b (diff) | |
| download | go-3380ee2520165187c3d1476c46d16bc76376d4d4.tar.xz | |
Revert "os/exec: make StdoutPipe and StderrPipe safe to Close concurrently"
This reverts CL 437176.
Reason for revert: broke programs that plumb StdoutPipe from one command to Stdin on another and then call Wait on the former.
os/exec itself uses a type-assertion to *os.File to determine whether to copy stdin using a goroutine or just pass a file descriptor. An early Wait using a *os.File is benign (because closing the pipe doesn't close the child's inherited file descriptor), but an early Wait using a non-*os.File is not.
Updates #50436.
Change-Id: I4a2993e290982834f91696d890dfe77364c0cc50
Reviewed-on: https://go-review.googlesource.com/c/go/+/438695
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/os/exec')
| -rw-r--r-- | src/os/exec/exec.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go index 66441ecadd..8e6f709a2f 100644 --- a/src/os/exec/exec.go +++ b/src/os/exec/exec.go @@ -808,9 +808,8 @@ func (c *Cmd) StdoutPipe() (io.ReadCloser, error) { } c.Stdout = pw c.childIOFiles = append(c.childIOFiles, pw) - rc := &closeOnce{File: pr} - c.parentIOPipes = append(c.parentIOPipes, rc) - return rc, nil + c.parentIOPipes = append(c.parentIOPipes, pr) + return pr, nil } // StderrPipe returns a pipe that will be connected to the command's @@ -834,9 +833,8 @@ func (c *Cmd) StderrPipe() (io.ReadCloser, error) { } c.Stderr = pw c.childIOFiles = append(c.childIOFiles, pw) - rc := &closeOnce{File: pr} - c.parentIOPipes = append(c.parentIOPipes, rc) - return rc, nil + c.parentIOPipes = append(c.parentIOPipes, pr) + return pr, nil } // prefixSuffixSaver is an io.Writer which retains the first N bytes |
