summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsimonmar <unknown>2005-01-14 11:46:24 +0000
committersimonmar <unknown>2005-01-14 11:46:24 +0000
commit5155d694cd4118c134dc74fe19348ac70e22433d (patch)
treef853020dfef2ffc5275149faee7dd287b0e1bb9f
parent20b21f5bd6cbb71919da4db7137d355ae5efe4ac (diff)
downloadhaskell-5155d694cd4118c134dc74fe19348ac70e22433d.tar.gz
[project @ 2005-01-14 11:46:24 by simonmar]
hGetStringBuffer: hClose the file after we've read it (duh). This causes a real problem on Windows, where the file remains locked in GHCi, and cannot be modified until after the finalizer has closed it (bug #1047408).
-rw-r--r--ghc/compiler/utils/StringBuffer.lhs4
1 files changed, 3 insertions, 1 deletions
diff --git a/ghc/compiler/utils/StringBuffer.lhs b/ghc/compiler/utils/StringBuffer.lhs
index 61a0321d71..a8c7a1ed63 100644
--- a/ghc/compiler/utils/StringBuffer.lhs
+++ b/ghc/compiler/utils/StringBuffer.lhs
@@ -49,7 +49,8 @@ import GHC.IOBase
import GHC.IO ( slurpFile )
#endif
-import IO ( openFile, hFileSize, IOMode(ReadMode) )
+import IO ( openFile, hFileSize, IOMode(ReadMode),
+ hClose )
#if __GLASGOW_HASKELL__ >= 601
import System.IO ( openBinaryFile )
#else
@@ -103,6 +104,7 @@ hGetStringBuffer fname = do
arr <- newArray_ (0,size_i-1)
r <- if size_i == 0 then return 0 else hGetArray h arr size_i
#endif
+ hClose h
if (r /= size_i)
then ioError (userError "short read of file")
else do