How to perform atomic copy of file through cp command.....
Hi all,
I m copying files from one directory to another directory from my C code. I have used system("cp -p source destination") function in my code to perform the file copy.
Now mean while, when the copying of file is in progress, through another script I m removing the files from source folder. Because of that my programe is failing.
I want to restrict the removal of files while my code is in execution. Once the the file copy is done then one can remove the file.
I want to know whether any mechanism is there to enforce atomicity while copying the files, i.e. while file copy is in progress then no othere process can delete the file.
If any body has any idea how to acomplish this task then please help me out....
[Note :: I m using C in Suse Linux.]
Thanking u all
With Regard
RajSun.
Last edited by rajsun; 12-07-2005 at 03:35 AM.
|