#3231: Permission denied error with runProcess/openFile
-------------------------+--------------------------------------------------
Reporter: NeilMitchell | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.10.2 | Severity: normal
Keywords: | Testcase:
Os: Windows | Architecture: Unknown/Multiple
-------------------------+--------------------------------------------------
Given this program:
{{{
module Main() where
import Control.Concurrent
import System.IO
import System.Process
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 AppendMode
hPutStrLn h "fakdjsklj"
putChar '.'
pid <- runProcess "sh" ["-c","sleep 0.1s"] Nothing Nothing Nothing
(Just h) (Just h)
waitForProcess pid
f file
}}}
Running under Cygwin, in GHC 6.10.2, I get:
{{{
$ runhaskell Test.hs
..Test.hs: foo1.txt: openFile: permission denied (Permission denied)
}}}
It shouldn't - the {{{openFile}}} calls should always succeed. This bug is
a reduced test case from a real system, which I papered over with:
{{{
retryIO :: IO a -> IO a
retryIO act = catchIO act $ \x -> do
threadDelay $ 1 * 1000000 -- 1 second
performGC
act
}}}
Now calling {{{retryIO $ openFile ...}}} works reliably. These problems
are occurring sufficiently often that {{{retryIO}}} is about to go in to
our standard library :-)
This may be related to #2924, but has the advantage of replicating easily.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3231>
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