Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2003-08-18
22:20 • Ticket [790399ffff] cd command is not thread safe status still Closed with 4... artifact: 12cb2e41d7 user: hobbs
22:15 • Closed ticket [790399ffff]. artifact: 75bdbf0db1 user: vincentdarley
16:49 • Ticket [790399ffff]: 7 changes artifact: 85b8438058 user: dkf
07:12 • New ticket [790399ffff]. artifact: 4334e5dd89 user: yahalom

cd command is not thread safe

Closed / Invalid790399ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 23 years ago
Descriptionplain2003-08-18 07:12:06
platform: windows 2000/Linux red hat
tcl version: 8.4.3 with thread support

when sending cd to a thread all threads changes the path.

package require Thread
set thread1 [thread::create]
puts "current: [pwd]"
thread::send $thread1 [list cd [file join c:/ tmp]]
puts "after: [pwd]"

result:
current: C:/
after: C:/tmp
dkfplain2003-08-18 16:49:23
Logged In: YES 
user_id=79902

Seems to me that this is just the way things are since the
concept of a current directory is defined by the OS as being
a process-level concept.  Which means that it is not a good
idea to use [cd] at all in threaded Tcl scripts; good thing
it is not actually necessary at all unless you have very
crufty external programs...

Do you agree, Vince?  If so, close this bug.  :^)
vincentdarleyplain2003-08-18 22:15:21
Logged In: YES 
user_id=32170

I agree.
hobbsplain2003-08-18 22:20:10
Logged In: YES 
user_id=72656

It is correct that cd is a process-wide item, but there were
some thread-safety issues when trying to cd from different
threads simultaneously in 8.4.3 that were corrected for
8.4.4.  In any case, the result received is correct.
Log in (anonymous is fine) to add a comment.