From b91b9ad43e67a984fef611ec9d5df0bfb226f35b Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 28 Jan 2011 00:01:08 +0000 Subject: [PATCH] When closing a file, call closedir if we called opendir. Fixes Go issue 1448. From-SVN: r169344 --- libgo/go/os/file_unix.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libgo/go/os/file_unix.go b/libgo/go/os/file_unix.go index aa322c96383..57d4a477fc6 100644 --- a/libgo/go/os/file_unix.go +++ b/libgo/go/os/file_unix.go @@ -47,6 +47,13 @@ func (file *File) Close() Error { if e := syscall.Close(file.fd); e != 0 { err = &PathError{"close", file.name, Errno(e)} } + + if file.dirinfo != nil { + if libc_closedir(file.dirinfo.dir) < 0 && err == nil { + err = &PathError{"closedir", file.name, Errno(syscall.GetErrno())} + } + } + file.fd = -1 // so it can't be closed again // no need for a finalizer anymore