LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Linux File Locking Mechanism (https://www.linuxquestions.org/questions/linux-kernel-70/linux-file-locking-mechanism-818530/)

Samrat_Chakravarty 07-07-2010 11:19 AM

Linux File Locking Mechanism
 
Hi Folks,

I have a situation where the one process 1 is writing files on Linux server and process 2 is polling for newly created files and reads them , making a copy and passes to another process.

Now, I want to know that is it possible that process 2 can read a file before the process 1 completely write it. Is there any kind of automatic kinda locking mechanism in Linux which stops process 2 to read the file before process 1 completely write it.

Any kind of help will be appreciable.

Thanks,
Samrat.

b0uncer 07-07-2010 12:50 PM

Named pipes/FIFOs might be one option. For a quick introduction, see for example this page on Linux Journal. The idea is that one program writes to a special place and the other one reads when it finds information there.


All times are GMT -5. The time now is 06:28 AM.