#4802: 'current directory' is not thread local
---------------------------------+------------------------------------------
    Reporter:  tanakh            |       Owner:                     
        Type:  bug               |      Status:  new                
    Priority:  normal            |   Component:  libraries/directory
     Version:  7.0.1             |    Keywords:                     
    Testcase:                    |   Blockedby:                     
          Os:  Unknown/Multiple  |    Blocking:                     
Architecture:  Unknown/Multiple  |     Failure:  Documentation bug  
---------------------------------+------------------------------------------
 In a threaded code, the current directory is not thread local, even using
 forkOS.

 For example:

 {{{
 import System.Directory
 import Control.Concurrent

 main :: IO ()
 main = do
   print =<< getCurrentDirectory

   forkOS $ do
     setCurrentDirectory "a"
     threadDelay $ 10^6
     print =<< getCurrentDirectory

   forkOS $ do
     threadDelay $ 10^6
     print =<< getCurrentDirectory

   threadDelay $ 20*10^6
 }}}

 The output is:

 {{{
 $ ghc --make -threaded curdir.hs
 [1 of 1] Compiling Main             ( curdir.hs, curdir.o )
 Linking curdir ...
 $ ./curdir
 "/home/hideyuki"
 "/home/hideyuki/a"
 "/home/hideyuki/a"
 }}}

 It seems to inherit the specification of pthread. It may be environment-
 dependent behavior (At least, on Linux and Windows, same results are
 given).

 If the behavior like above is the specific, documents should be added to
 setCurrentDirectory/getCurrentDirectory. It is very confusing.

 Or if it is possible to wrap the behabior of 'current directory' to make
 thread local in Haskell code, I hope to make it so.

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