aboutsummaryrefslogtreecommitdiff
path: root/src/lib/os
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-04-29 18:18:42 -0700
committerRuss Cox <rsc@golang.org>2009-04-29 18:18:42 -0700
commitf7d3eb9db97a65a43b8d6b8bf42b8698fe4468ee (patch)
tree6520908cabf28e784f54b52c79cda2fcf2e5e500 /src/lib/os
parent2cf5c809d01b9965ffb68f94426e2afc977552ed (diff)
downloadgo-f7d3eb9db97a65a43b8d6b8bf42b8698fe4468ee.tar.xz
exit with error status EPIPE if
one fd gets too many EPIPEs in a row during write. R=r DELTA=10 (9 added, 0 deleted, 1 changed) OCL=28057 CL=28057
Diffstat (limited to 'src/lib/os')
-rw-r--r--src/lib/os/file.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lib/os/file.go b/src/lib/os/file.go
index d7ea573fc5..fa1784a426 100644
--- a/src/lib/os/file.go
+++ b/src/lib/os/file.go
@@ -23,6 +23,7 @@ type File struct {
fd int64;
name string;
dirinfo *dirInfo; // nil unless directory being read
+ nepipe int; // number of consecutive EPIPE in Write
}
// Fd returns the integer Unix file descriptor referencing the open file.
@@ -40,7 +41,7 @@ func NewFile(file int64, name string) *File {
if file < 0 {
return nil
}
- return &File{file, name, nil}
+ return &File{file, name, nil, 0}
}
// Stdin, Stdout, and Stderr are open Files pointing to the standard input,
@@ -128,6 +129,14 @@ func (file *File) Write(b []byte) (ret int, err Error) {
r = 0
}
}
+ if e == syscall.EPIPE {
+ file.nepipe++;
+ if file.nepipe >= 10 {
+ sys.Exit(syscall.EPIPE);
+ }
+ } else {
+ file.nepipe = 0;
+ }
return int(r), ErrnoToError(e)
}