It might be worthwhile mentioning why you need to check if a file is already open, and what exactly you mean by that. For instance, if a program has opened a given file with an advisory flock and expects mutual flocking your script can still read/write it's contents, even if that will perhaps lead to unpredictable results. It all comes down to what you are trying to achieve.
Sometimes, the solution to a problem comes along easier if the whole picture is presented. It's like a painting. You are showing us a tree, and we say "nice". But you never mention about the beautiful lake right beside it, which makes us go "wow". ;) | [reply] [d/l] [select] |
Here's a scenario
I have a configuration file, say config.txt. which actually gets updated by one of my programs, say update_config.pl. Now, a user can open the file and see the content of the file, config.txt while somebody else is using the update_config.pl program. Now, if the user who had kept the config.txt file opened saves while closing te file, the change made by the update_config.pl is lost.
I want to avoind this situation.
I hope i've painted the picture of my lake to your liking :)
| [reply] |