There is a file which is locked by another process for editing. Is there any way to open the file in exclusive mode using the C program?
A:
Yes, kill the other process. An OS otherwise of course does not provide a way to allow you to open a locked file, that would utterly defeat the point of supporting locking.
Fwiw, a pretty common mistake is to try to open a file that another process has opened for writing and specifying only read sharing. Can't work, the other process already gained write access. You must specify read+write sharing.
Hans Passant
2010-09-21 10:29:48
I cannot kill the other process.
Pradeep
2010-09-21 10:44:42
From above comments,I think there is no way to open the locked file in exclusive mode.
Pradeep
2010-09-21 10:45:15
@Pradeep: Do you understand that there are a contradiction in your question? You can not go through the only closed door without opening it or breaking it!
Oleg
2010-09-21 10:56:59