setCurrentDirectory and lightweight threads

Niklas Broberg niklas.broberg at gmail.com
Sun Oct 24 12:41:16 EDT 2004


> > What I mean is that if one page wants to change directory using
> > setCurrentDirectory, this change affects all other (lightweight)
> > threads as well, which is not how "ordinary" system threads works.
> 
> AFAIK, this _is_ how "ordinary" system threads work. 

Hmm, I guess was confused (and is still) by the distinction between
threads and processes. The following quote comes from one of your
links:

  The current working directory is shared between all threads within the same
  process. Therefore, one thread using the chdir() or fchdir() functions
  will affect every other thread in that process.

So that means you're right, and that the current directory shouldn't
be tampered with in a multithreaded setting. I still don't understand
*why* it is like this on the OS level, but I'm not going to opt for a
change there. ;o)

I guess that leaves me to implement a add layer on top of IO that can
handle "directory state" of different threads. Oh well. =)

Thanks for the answer,

/Niklas


More information about the Glasgow-haskell-users mailing list