From: Russ Cox Date: Thu, 30 Apr 2009 01:18:42 +0000 (-0700) Subject: exit with error status EPIPE if X-Git-Tag: weekly.2009-11-06~1742 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f7d3eb9db97a65a43b8d6b8bf42b8698fe4468ee;p=gostls13.git 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 --- 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) }