diff options
Diffstat (limited to 'src/os/exec/exec.go')
| -rw-r--r-- | src/os/exec/exec.go | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go index e3c6fb62b1..1f5fb6e39c 100644 --- a/src/os/exec/exec.go +++ b/src/os/exec/exec.go @@ -157,6 +157,11 @@ func (c *Cmd) argv() []string { return []string{c.Path} } +// skipStdinCopyError optionally specifies a function which reports +// whether the provided the stdin copy error should be ignored. +// It is non-nil everywhere but Plan 9, which lacks EPIPE. See exec_posix.go. +var skipStdinCopyError func(error) bool + func (c *Cmd) stdin() (f *os.File, err error) { if c.Stdin == nil { f, err = os.Open(os.DevNull) @@ -180,16 +185,9 @@ 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 { + if skip := skipStdinCopyError; skip != nil && skip(err) { err = nil } - if err1 := pw.Close(); err == nil { err = err1 } |
