Commit f7d3eb9d authored by Russ Cox's avatar Russ Cox

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
parent 2cf5c809
......@@ -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)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment