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

 > > This appears to be a duplicate of #2650? I have some partial fixes for
 the issue there.
 >
 > So the fix to add `_O_NOINHERIT` when opening files could be applied,
 but I'm not sure whether it will have any undesirable consequences.
 Anyone?

 If there is no way to implement the `close_fds` parameter to
 `createProcess` properly on Windows, that should at least be mentioned in
 the documentation! Since the parameter is there, I'd prefer to have it
 implemented, rather than ignored, though.

 Anyway, that means we can simplify the example, right?
 {{{
 module Main() where

 import Control.Concurrent
 import System.IO
 import System.Process

 my_system str = do
   (_,_,_,p) <- createProcess c
   waitForProcess p
   where c = CreateProcess { cmdspec = ShellCommand str,
                             cwd = Nothing,
                             env = Nothing,
                             std_in = Inherit,
                             std_out = Inherit,
                             std_err = Inherit,
                             close_fds = True } -- close_fds is ignored on
 windows!-(

 main = do
   va <- newEmptyMVar
   vb <- newEmptyMVar
   forkIO $ p va vb "foo1.txt"
   takeMVar va
   forkIO $ my_system "sleep 60s" >> return ()
   putMVar vb ()
   putStrLn "Finished"

 p va vb file = do
   h <- openFile file WriteMode
   putMVar va ()
   takeMVar vb
   hClose h
   h <- openFile file WriteMode
   putStrLn "Success?"
   hClose h
 }}}
 Seems to fail quite reliably here, while it works when the system call is
 commented out.

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