Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Working directory in thread

Reply
Thread Tools

Working directory in thread

 
 
Xiangrong Fang
Guest
Posts: n/a
 
      08-07-2003
Hi

I have a question using Dir.chdir. Is the current working directory for
a program unique to thread or to the program? My multithread program is
experiencing problems. It seems that a Dir.chdir in one thread changed
the working directory of another thread. Is there a "thread-safe" chdir?

Thanks!

--
Xiangrong Fang <(E-Mail Removed)>


 
Reply With Quote
 
 
 
 
Hal E. Fulton
Guest
Posts: n/a
 
      08-07-2003
----- Original Message -----
From: "Xiangrong Fang" <(E-Mail Removed)>
To: "ruby-talk ML" <(E-Mail Removed)>
Sent: Wednesday, August 06, 2003 10:49 PM
Subject: Working directory in thread


> I have a question using Dir.chdir. Is the current working directory for
> a program unique to thread or to the program? My multithread program is
> experiencing problems. It seems that a Dir.chdir in one thread changed
> the working directory of another thread. Is there a "thread-safe" chdir?


An OS issue. The notion of the current directory
is per-process.

Not possible to do what you want *unless* you
support it yourself... e.g., do some syncing at
the same time you change dirs.

mutex.synchronize do
Dir.chdir(newdir) do
# code...
end
end

But if you were going to do that, it might be
almost as easy just to keep the dir info for
each thread and stick it on the front of each
filename or whatever.

Hal

--
Hal Fulton
http://www.velocityreviews.com/forums/(E-Mail Removed)



 
Reply With Quote
 
 
 
 
nobu.nokada@softhome.net
Guest
Posts: n/a
 
      08-07-2003
Hi,

At Thu, 7 Aug 2003 12:49:31 +0900,
Xiangrong Fang wrote:
> I have a question using Dir.chdir. Is the current working directory for
> a program unique to thread or to the program? My multithread program is
> experiencing problems. It seems that a Dir.chdir in one thread changed
> the working directory of another thread. Is there a "thread-safe" chdir?


CWD is a process resource. There is no "thread-safe" way, in
general.

--
Nobu Nakada

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
System.IO.Directory.GetDirectories() and System.IO.Directory.GetFiles() are not returning the specified directory Nathan Sokalski ASP .Net 2 09-06-2007 03:58 PM
Terminating a thread from the main thread Charles A. Lackman ASP .Net 3 12-09-2004 02:12 PM
"Thread was being aborted" error from WebApp using Thread.Sleep. Stephen Miller ASP .Net 3 07-01-2004 11:50 PM
Runtime.exec() with env and working directory parameters is not working. Priyanka AGARWAL Java 9 05-25-2004 02:34 PM
perl 5.8.2/3 - thread started by a thread pawo Perl 0 02-16-2004 01:18 PM



Advertisments