Ticket #3231 (new bug)
Permission denied error with runProcess/openFile
| Reported by: | NeilMitchell | Owned by: | simonmar |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.6.2 |
| Component: | libraries/base | Version: | 6.10.4 |
| Keywords: | Cc: | ndmitchell@…, lennart@… | |
| Operating System: | Windows | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | Unknown |
| Test Case: | Blocked By: | ||
| Blocking: | Related Tickets: |
Description
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.
Change History
Note: See
TracTickets for help on using
tickets.
