[darcs-users] DeleteFile on Windows

Petr Rockai me at mornfall.net
Tue Oct 27 11:41:38 UTC 2009


Ok, since I was a little (too) curious, I have tried the following testcase:

main = do x <- mmapFileByteString "test.hs.out" Nothing
          h <- createFile "test.hs.out"
                     dELETE
                     fILE_SHARE_NONE
                     Nothing
                     oPEN_ALWAYS
                     fILE_FLAG_DELETE_ON_CLOSE
                     Nothing
          -- removeFile "test.hs.out"
          putStrLn "hey there"
          closeHandle h
          putStrLn "closed..."
          print x

This program dies with a page-in failure on the last line (print x). However,
this is probably a bug in the mmap package, which closes the filehandle even
though the mapping is still live. The resulting behaviour is almost certainly a
win32 bug, but it should be possible to fix within mmap (by clinging onto the
filehandle until everything is unmapped).

Yours,
   Petr.

PS: (To try yourself, you have to create nonempty test.hs.out before calling
the program. I tried with mmap 0.4.2 which we currently use, may be it is
already fixed in 0.5.x, but that will need a little porting effort on
hashed-storage side.)


More information about the darcs-users mailing list