diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2015-07-13 18:17:24 -0600 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2015-07-14 00:41:31 +0000 |
commit | 73ca459a56ef003ad0892ef46454bc98afd30a05 (patch) | |
tree | 5fec32de411d15ee26497d08ee23e87e2d00bbce /src/os/exec/exec.go | |
parent | 3c5eb96001453466656873a2d5c8921d8baebfcd (diff) | |
download | go-73ca459a56ef003ad0892ef46454bc98afd30a05.tar.gz go-73ca459a56ef003ad0892ef46454bc98afd30a05.zip |
os/exec: ignore pipe write errors when command completes successfully
Fixes #9173
Change-Id: I83530533db84b07cb88dbf6ec690be48a06a9d7d
Reviewed-on: https://go-review.googlesource.com/12152
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/os/exec/exec.go')
-rw-r--r-- | src/os/exec/exec.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go index a263795814..e3c6fb62b1 100644 --- a/src/os/exec/exec.go +++ b/src/os/exec/exec.go @@ -180,6 +180,16 @@ func (c *Cmd) stdin() (f *os.File, err error) { c.closeAfterWait = append(c.closeAfterWait, pw) c.goroutine = append(c.goroutine, func() error { _, err := io.Copy(pw, c.Stdin) + + // Ignore EPIPE errors copying to stdin if the program + // completed successfully otherwise. + // See Issue 9173. + if pe, ok := err.(*os.PathError); ok && + pe.Op == "write" && pe.Path == "|1" && + pe.Err == syscall.EPIPE { + err = nil + } + if err1 := pw.Close(); err == nil { err = err1 } |