#3231: Permission denied error with runProcess/openFile
--------------------------+-------------------------------------------------
Reporter: NeilMitchell | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.10.2
Severity: normal | Resolution:
Keywords: | Testcase:
Os: Windows | Architecture: Unknown/Multiple
--------------------------+-------------------------------------------------
Comment (by NeilMitchell):
Another version, this time not tying the process to a handle:
{{{
module Main() where
import Control.Concurrent
import System.IO
import System.Cmd
import System.Directory
main = do
hSetBuffering stdout NoBuffering
forkIO $ f "foo1.txt"
forkIO $ f "foo2.txt"
threadDelay $ 100*1000000
putStrLn "Finished successfully"
f file = do
h <- openFile file WriteMode
hPutStrLn h "fjkladsf"
system "sleep 1s"
putChar '.'
hClose h
removeFile file
f file
}}}
This version fails under both Cygwin and from the Windows command prompt
with:
{{{
$ runhaskell Test.hs
.Test.hs: DeleteFile: permission denied (The process cannot access the
file beca
use it is being used by another process.)
}}}
This version works fine if the {{{system}}} call is removed. That call
shouldn't have any difference to the usage of any handles. It seems that
system calls mess with handles and resources in painful ways. This is now
almost certainly the same underlying cause as the problems I reported in
bug #2924.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3231#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs