From: "ara.t.howard" Date: 2008-09-10T05:37:16+09:00 Subject: Re: FileUtils.chdir thread safety On Sep 9, 2008, at 1:46 PM, Joel VanderWerf wrote: > So in the case of > > Thread.chdir('foo') {puts `ls`} > > the subprocess would be executed in foo ? > > This would be very nice, but it seems like a major modification to > ruby... potentially every system call would need to be aware of the > thread cwd state. this is already true. if you do chdir('foo'){ puts `ls` } the command will enter foo, run ls, and exit. the real issue is with Thread.new do chdir 'foo' puts `ls` end Thread.new do chdir 'foo' puts `ls` end it's a race condition currently, though i assume that's what you meant joel. a thread local 'chdir' would need to affect backticks, system, exec, Dir methods, FileUtils methods, etc. i guess the first thing scheduling each thread would need to do is chdir to it's own cwd before running any code to be safe. this seems *very* expensive doesn't it? it seems like an easier a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama