os: add ErrClosed, return for use of closed File

This is clearer than syscall.EBADF.

Fixes #17320.

Change-Id: I14c6a362f9a6044c9b07cd7965499f4a83d2a860
Reviewed-on: https://go-review.googlesource.com/30614
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Dan Caddigan 2016-10-07 00:46:56 -04:00 committed by Brad Fitzpatrick
parent 452bbfc179
commit 212d2f82e0
10 changed files with 70 additions and 30 deletions

View file

@ -128,7 +128,7 @@ func (f *File) Close() error {
}
func (file *file) close() error {
if file == nil || file.fd < 0 {
if file == nil || file.fd == badFd {
return syscall.EINVAL
}
var err error