setCurrentDirectory and lightweight threads

Niklas Broberg niklas.broberg at
Sat Oct 23 12:08:28 EDT 2004

Hello fellow Haskelleers,

I've come upon a problem that sort of bites me. 
I'm writing a multithreaded webserver in which pages are dynamically
loaded haskell applications. The main server loop listens for incoming
requests and distributes these to request handlers, each running in a
separate lightweight thread.

Now, some of the most common operations used in dynamic web pages
relate to directory listing/manipulation. I was happily thinking that
System.Directory would provide the needed functionality. Indeed it
does, but unfortunately setCurrentDirectory breaks the thread
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.
Also it is clearly not what one would want in the kind of application
I'm writing.

Is this behavior of setCurrentDirectory intended? I can't see a
situation in which you could take advantage of it, but that doesn't
mean there can't be any. =)

If it is not intended, is there any hope of it being "fixed"? 



More information about the Glasgow-haskell-users mailing list