id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,os,architecture,failure,difficulty,testcase,blockedby,blocking,related
4802,'current directory' is not thread local,tanakh,simonmar,"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.
",bug,closed,normal,7.2.1,libraries/directory,7.0.1,fixed,,tanaka.hideyuki@…,Unknown/Multiple,Unknown/Multiple,Documentation bug,,,,,
