#2458 cd command is not thread safe

obsolete: 8.4.3
closed-invalid
5
2003-08-18
2003-08-18
No

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

Discussion

  • Donal K. Fellows

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

     
  • 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
    user_id=32170

    I agree.

     
  • Jeffrey Hobbs

    Jeffrey Hobbs - 2003-08-18

    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.