]> Cypherpunks repositories - gostls13.git/commit
os/exec: remove protection against a duplicate Close on StdinPipe
authorBryan C. Mills <bcmills@google.com>
Wed, 5 Oct 2022 18:04:55 +0000 (14:04 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 11 Oct 2022 14:31:32 +0000 (14:31 +0000)
commit0f64a49460974fa65292d8d5bf6c8a9ceca4b780
treecc77617eeda5dca99a02d56c13c45bc511ebef0c
parent1b316e3571190964d960c6a7af3e17e887c70d45
os/exec: remove protection against a duplicate Close on StdinPipe

As of CL 438347, multiple concurrents calls to Close should be safe.

This removes some indirection and may also make some programs that use
type-assertions marginally more efficient. For example, if a program
calls (*exec.Cmd).StdinPipe to obtain a pipe and then sets that as the
Stdout of another command, that program will now allow the second
command to inherit the file descriptor directly instead of copying
everything through a goroutine.

This will also cause calls to Close after the first to return an error
wrapping os.ErrClosed instead of nil. However, it seems unlikely that
programs will depend on that error behavior: if a program is calling
Write in a loop followed by Close, then if a racing Close occurs it is
likely that the Write would have already reported an error. (The only
programs likely to notice a change are those that call Close — without
Write! — after a call to Wait.)

Updates #56043.
Updates #9307.
Updates #6270.

Change-Id: Iec734b23acefcc7e7ad0c8bc720085bc45988efb
Reviewed-on: https://go-review.googlesource.com/c/go/+/439195
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/os/exec/exec.go
src/os/exec/exec_test.go