[GHC] #4363: openFile sharing permissions are inconsistent across platforms

GHC cvs-ghc at haskell.org
Mon Oct 4 05:28:38 EDT 2010


#4363: openFile sharing permissions are inconsistent across platforms
---------------------------------+------------------------------------------
    Reporter:  jystic            |       Owner:                             
        Type:  bug               |      Status:  new                        
    Priority:  normal            |   Component:  libraries/base             
     Version:  6.12.3            |    Keywords:                             
    Testcase:                    |   Blockedby:                             
          Os:  Windows           |    Blocking:                             
Architecture:  Unknown/Multiple  |     Failure:  Incorrect result at runtime
---------------------------------+------------------------------------------
 System.IO.openFile seems to have inconsistent behaviour across platforms
 regarding file sharing permissions.

 Given this program:
 {{{
 {-# LANGUAGE CPP #-}

 import System.IO
 import System.Process

 main = do
     h <- openFile "file.txt" WriteMode
     hPutStrLn h "Success! I can see the file's contents."
     hFlush h
 #ifdef mingw32_HOST_OS
     system "type file.txt"
 #else
     system "cat file.txt"
 #endif
     hClose h
 }}}

 Running under Ubuntu 10.04 / GHC 6.12.1, I get:
 {{{
 $ runghc openFile.hs
 Success! I can see the file's contents.
 }}}

 Running under Windows 7 / GHC 6.12.3, I get:
 {{{
 > runghc openFile.hs
 The process cannot access the file because it is being used by another
 process.
 }}}

 In my opinion the behaviour exhibited by Linux is preferable because it
 allows for log files to be written by long running processes. These log
 files can then be inspected externally while the Haskell process is still
 running.

 The Snap Framework (snapframework.com) does this and it works great on
 Linux / Mac OS, but on Windows the log files cannot be viewed until after
 the server is shut down.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4363>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the Glasgow-haskell-bugs mailing list