Skip to content

Commit a3dc6da

Browse files
fhsbradfitz
authored andcommitted
os/exec: ignore hungup error while copying stdin on Plan 9
Fixes #35753 Change-Id: I38674c59c601785eb25b778dc25efdb92231dd9b Reviewed-on: https://go-review.googlesource.com/c/go/+/208223 Run-TryBot: Emmanuel Odeke <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 7d30af8 commit a3dc6da

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

src/os/exec/exec.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ func (c *Cmd) argv() []string {
238238

239239
// skipStdinCopyError optionally specifies a function which reports
240240
// whether the provided stdin copy error should be ignored.
241-
// It is non-nil everywhere but Plan 9, which lacks EPIPE. See exec_posix.go.
242241
var skipStdinCopyError func(error) bool
243242

244243
func (c *Cmd) stdin() (f *os.File, err error) {

src/os/exec/exec_plan9.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package exec
6+
7+
import "os"
8+
9+
func init() {
10+
skipStdinCopyError = func(err error) bool {
11+
// Ignore hungup errors copying to stdin if the program
12+
// completed successfully otherwise.
13+
// See Issue 35753.
14+
pe, ok := err.(*os.PathError)
15+
return ok &&
16+
pe.Op == "write" && pe.Path == "|1" &&
17+
pe.Err.Error() == "i/o on hungup channel"
18+
}
19+
}

src/os/exec/exec_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -974,11 +974,6 @@ func (delayedInfiniteReader) Read(b []byte) (int, error) {
974974
func TestIgnorePipeErrorOnSuccess(t *testing.T) {
975975
testenv.MustHaveExec(t)
976976

977-
// We really only care about testing this on Unixy and Windowsy things.
978-
if runtime.GOOS == "plan9" {
979-
t.Skipf("skipping test on %q", runtime.GOOS)
980-
}
981-
982977
testWith := func(r io.Reader) func(*testing.T) {
983978
return func(t *testing.T) {
984979
cmd := helperCommand(t, "echo", "foo")

0 commit comments

Comments
 (0)