I am having trouble with multiple sessions writting to the same file. I keep losing info and complete entries. I think I have a timing issue with the sessions stepping on each oither as they try to access the file. I have no idea as how to stop the sessions from stepping on each other. Below is the coding that I am using now. Thanks
proc WriteLog {fileName msg} {
while 1 {
if {[file exists $fileName]} {
if {![catch {open $fileName a} fn]} {
puts $fn $msg
flush $fn
close $fn
return
} else {
continue
}
} else {
if {![catch {open $fileName w} fn]} {
puts $fn $msg
flush $fn
close $fn
return
} else {
continue
}
}
}
}
proc WriteLog {fileName msg} {
while 1 {
if {[file exists $fileName]} {
if {![catch {open $fileName a} fn]} {
puts $fn $msg
flush $fn
close $fn
return
} else {
continue
}
} else {
if {![catch {open $fileName w} fn]} {
puts $fn $msg
flush $fn
close $fn
return
} else {
continue
}
}
}
}