[fpc-pascal] File locking/protection in Linux

Michael Van Canneyt michael at freepascal.org
Wed Nov 2 09:24:40 CET 2005



On Wed, 2 Nov 2005, Antal wrote:

> How can be avoided in Linux the file corruption due to simultaneous write 
> access from two different process?
> Or how can it be avoided to access the same file by two different process?
> I experienced a few (but painful) data loss due to this problem, and I'm 
> unable to solve the problem.

You can use the fpflock call (unit 'unix') to lock (parts of) a file.
But be aware that BOTH processes must use this mechanism;
File locking is optional on Linux.
Nothing prevents a third process from using the file without locks.

Michael.



More information about the fpc-pascal mailing list