mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-07-29 13:29:46 +02:00

whose size depends on whether the run time environment is 32 or 64 bit (mantis #13647) + added flock64 type for 32 bit systems (usable with special 64 bit fcntl operations) git-svn-id: trunk@13119 -
41 lines
879 B
ObjectPascal
41 lines
879 B
ObjectPascal
{ %target=linux }
|
|
|
|
program setup;
|
|
|
|
{$mode delphi}{$H+}
|
|
|
|
Uses cthreads, Classes, SysUtils, BaseUnix;
|
|
|
|
{ don't use current directory in case it's on a network share that does not
|
|
support locking
|
|
}
|
|
Const Fn = '/tmp/fpctest.lock';
|
|
F_RDLCK = 0;
|
|
F_WRLCK = 1;
|
|
F_UNLCK = 2;
|
|
|
|
Var F, I : Integer;
|
|
Region : FLock;
|
|
res: longint;
|
|
Begin
|
|
If FileExists (Fn) Then DeleteFile (Fn);
|
|
F := FpOpen (Fn, O_RDWR Or O_CREAT, $1B6); // $1B6 = o666
|
|
For I := 0 To 255 Do FpWrite (F, I, 1);
|
|
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
|
|
begin
|
|
FpClose (F);
|
|
deletefile(fn);
|
|
halt(1);
|
|
end;
|
|
res:=executeprocess('./tb0561a','');
|
|
FpClose (F);
|
|
deletefile(fn);
|
|
if res<>0 then
|
|
halt(2);
|
|
End.
|
|
|