#2458 cd command is not thread safe

obsolete: 8.4.3

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]"

current: C:/
after: C:/tmp


  • Donal K. Fellows

    Logged In: YES

    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. :^)

  • Donal K. Fellows

    • milestone: --> obsolete: 8.4.3
    • assigned_to: dkf --> vincentdarley
    • status: open --> open-invalid
  • Vince Darley

    Vince Darley - 2003-08-18
    • status: open-invalid --> closed-invalid
  • Vince Darley

    Vince Darley - 2003-08-18

    Logged In: YES

    I agree.

  • Jeffrey Hobbs

    Jeffrey Hobbs - 2003-08-18

    Logged In: YES

    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.