[Lazarus] semaphore
Antonio Fortuny
a.fortuny at sitasoftware.lu
Thu Feb 16 17:04:34 CET 2012
Hi all.
On an OpenSuse 12.1, Lazarus 0.9.31, FPC 2.4.4 I can't create a semaphore
Code:
LockerS: Integer;
SemKey: Integer;
SemKey := strToIntDef(ESemaphoreKey.Text, -1);
if SemKey = -1 then
Break;
LockerS := semget(SemKey, 1, 0666 + IPC_CREAT + IPC_EXCL);
if LockerS >= 0 then begin
// got the semaphore: initialize it
Args.Val := 1;
Ret := semctl(LockerS, 0, SEM_SETVAL, Args);
if Ret >= 0 then begin
// semaphore locked; get out
Operation.sem_op := -1; //reduce the semaphore count to lock
Operation.sem_num := 0; //signifies 0th semaphore
Operation.sem_flg := IPC_EXCL; // fail if key exists
Ret := semop(LockerS, @Operation,1);
if Ret >= 0 then
Break;
end
end else begin
LastError := errno;
LastErrorText := strerror(LastError);
Memo1.Lines.Add(Format('semaphore locker not created
errno:%d-%s', [LastError, LastErrorText]));
end
*semget *always returns -1 with errno set to 2 (?) whatever the contents
of *SemKey* could be.
What is wrong ?
Antonio.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20120216/496bedc4/attachment-0002.html>
More information about the Lazarus
mailing list