how do you check if a file ( a.txt ) is being used by another process?Code:int main(int argc,char *argv[]) { if ( no Being used by another process ) remove("a.txt"); return 0; }
thanks.
how do you check if a file ( a.txt ) is being used by another process?Code:int main(int argc,char *argv[]) { if ( no Being used by another process ) remove("a.txt"); return 0; }
thanks.
It depends on your OS.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
use lsof ./a.txt. This will show you not only how many processes of a file open but who they are. Hint: this also works on sockets too
Don't ask me; I only code for Windows if there is a gun pointing at my head...all kidding aside there are a lot of Redmond-ites here that I am sure would be happy to tell you..cool thing about NIX though is you can get the source code to lsof and code it right into your app