one process open file for writing, one more process also open same file for writing in this situvation file is courupted, how can we lock that file when process open that one from another one
File creation is an atomic operation; that's why you see .lck files all over the place.
Before you want to write to a file "foo", attempt to create a file "foo.lck". If that
succeeds you can wite to "foo". When you're ready writing, remove file "foo.lck"
again. If the creation failed, something else is writing to file "foo" so you should
wait a bit or try again or whatever.
kind regards,
Jos