[fpc-devel] How to use fpFlock?

amir amir at aavani.net
Fri May 2 04:35:19 CEST 2008


I have many process wanting to write in a file. Each process is going to 
open the file as a writeonly (using Assignfile and rewrite or fpOpen 
with o_WrOnly). But there is a risk that two processes simultaneously 
trying to write a message in the file. I want to use fpflock to avoid 
this. Is it possible? What I done is something like this:

AssignFile (OutputFile, FileName);
fpflock (OutputFile, LOCK_EX);
Rewrite (OutputFile);

The description of fpFlock does not  say anything about the default 
behavior of fpFlock (Is it blocking?). What I saw told me that it is not 

Is it the correct way of using fpFlock?

More information about the fpc-devel mailing list