#3231: Permission denied error with runProcess/openFile
---------------------------------+------------------------------------------
    Reporter:  NeilMitchell      |        Owner:  simonmar
        Type:  bug               |       Status:  closed  
    Priority:  normal            |    Milestone:  6.12.1  
   Component:  Runtime System    |      Version:  6.10.4  
    Severity:  normal            |   Resolution:  invalid 
    Keywords:                    |   Difficulty:  Unknown 
    Testcase:                    |           Os:  Windows 
Architecture:  Unknown/Multiple  |  
---------------------------------+------------------------------------------
Comment (by yugr):

 Hi all,

 Sorry to bother you once again but I think we may still have problem with
 #3231 (http://hackage.haskell.org/trac/ghc/ticket/3231).

 Before I go into details have a look at the code below - is it free from
 problem with lazy IO which you mentioned above?

 I am still running into errors with a small multi-process program:
 bug.exe: mytempfile.txt: openFile: permission denied (Permission denied)
 or if I remove if-then-else
 bug.exe: DeleteFile: permission denied ...

 {{{
 module Main where

 import System
 import System.IO
 import System.Process (runProcess, waitForProcess)
 import System.Directory (removeFile)

 import Control.Monad (replicateM_)
 import Control.Parallel (pseq)

 import qualified Data.ByteString as B

 run :: FilePath -> IO ()
 run exe = do
   let tempFile = "mytempfile.txt"

   h <- openFile tempFile WriteMode

   exitCode <- waitForProcess =<< runProcess exe [] Nothing Nothing Nothing
 (Just h) (Just h)

   hClose h >> (if exitCode /= ExitSuccess then return () else B.readFile
 tempFile >>= B.putStr) >> removeFile tempFile

 main = replicateM_ 100 (putStrLn "Next:" >> run "a.exe")
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3231#comment:31>
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

Reply via email to