[fpc-pascal] File region locking unde Linux
Jonas Maebe
jonas.maebe at elis.ugent.be
Sun May 3 14:51:06 CEST 2009
On 03 May 2009, at 14:09, ajv wrote:
> With Region Do Begin
> l_type := F_WRLCK; l_whence := SEEK_SET;
> l_start := 10; l_len := 20
> End;
> If FpFcntl (F, F_SETLK, Region) = -1 Then
> WriteLn ('unable to apply writelock'); // <-- OK
> Sleep (20000); // Sleep 20 Sec
> FpClose (F);
> End.
> --------------------------------------------------------------------------------------
> Then within 20 seconds i start test to obtain a readlock on 80.
> This fails. Why? What am I doing wrong?
Your test works fine under Solaris. It's a bug somewhere in the FPC
Linux units. strace shows this for your first program:
fcntl(3, F_SETLK, {type=F_WRLCK, whence=SEEK_SET, start=10, len=0}) = 0
As you can see, "len=0" is passed to the system call (instead of
len=20), so it locks the entire file. That's the reason why the other
program is unable to lock anything else.
Jonas
More information about the fpc-pascal
mailing list