Re: How to wait for file closing?
- Posted by useless_ Dec 10, 2012
- 1759 views
ChrisB said...
The C++ program at the same time creates and deletes yumyum.lck whenever it opens and closes the file
That is how I would do it without having to worry about how the OS handles file locking and releasing.
There are probably better, and more sophisticated ways of doing it though.
Chris
You're correct. The biggest problem with using the OS to lock a file is if the app crashes, the file remains locked, and no one can use it until you manually unlock it.
The filesystem can be abused this way tho: any app that wants access to the file can write a filename-req-appname.txt file (or some other more imaginitive name), and then dir(filename-req-*.txt) will list the access queue for the file.
useless