mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
3c5eb96001
commit
73ca459a56
2 changed files with 31 additions and 0 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue