diff options
author | Russ Cox <rsc@golang.org> | 2015-07-22 16:50:00 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2015-07-22 21:37:18 +0000 |
commit | 92390e47d81713d13b0d9890bf8b153f142a5b8a (patch) | |
tree | 5d61d265f127cab0db0a35049ef3f815767cfd33 /src/os/exec/exec.go | |
parent | a5caa7c94eda915ee5e5ff82d81a22b8392d84aa (diff) | |
download | go-92390e47d81713d13b0d9890bf8b153f142a5b8a.tar.gz go-92390e47d81713d13b0d9890bf8b153f142a5b8a.zip |
os/exec: close read pipe if copy to io.Writer fails
Fixes #10400.
Change-Id: Ic486cb8af4c40660fd1a2e3d10986975acba3f19
Reviewed-on: https://go-review.googlesource.com/12537
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/os/exec/exec.go')
-rw-r--r-- | src/os/exec/exec.go | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go index fcc37870ed..8a84e263dc 100644 --- a/src/os/exec/exec.go +++ b/src/os/exec/exec.go @@ -230,6 +230,7 @@ func (c *Cmd) writerDescriptor(w io.Writer) (f *os.File, err error) { c.closeAfterWait = append(c.closeAfterWait, pr) c.goroutine = append(c.goroutine, func() error { _, err := io.Copy(w, pr) + pr.Close() // in case io.Copy stopped due to write error return err }) return pw, nil |