Wondering if one file is open for writing in and another programe is accessing it recursively in tcl.
views:
36answers:
3I don't think it's harmful to open a file for reading that's already opened for writing in another process. Depending on how the writing process buffers its output, all the data you might expect to see may not actually be written to the file yet.
You have a unique file descriptor, so you don't have to worry about someone else's file seek messing up yours. Just be aware that the data can change at any time, without warning. Also, make sure that the other program won't be truncating the file at any point in time; if it does, it can leave you suddenly and unexpectedly reading from an invalid address. If the other app is simply appending data (as in a logger flushing data to a logfile), then you shouldn't have to worry about that.
If the other app is sensitive enough that having your app read the file concurrently would mess it up, then it should be changing the file permissions to deny read access while it is modifying the file.
I wonder.. When one file is opened for reading, does it contents transfert to memory ? So, if somebody else change it after it is opened for reading, will it affect the program that only wants to read it ?