<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi all.<br>
<br>
On an OpenSuse 12.1, Lazarus 0.9.31, FPC 2.4.4 I can't create a
semaphore<br>
Code:<br>
<br>
LockerS: Integer;<br>
SemKey: Integer;<br>
<br>
<br>
SemKey := strToIntDef(ESemaphoreKey.Text, -1);<br>
if SemKey = -1 then<br>
Break;<br>
LockerS := semget(SemKey, 1, 0666 + IPC_CREAT + IPC_EXCL);<br>
if LockerS >= 0 then begin<br>
// got the semaphore: initialize it<br>
Args.Val := 1;<br>
Ret := semctl(LockerS, 0, SEM_SETVAL, Args);<br>
if Ret >= 0 then begin<br>
// semaphore locked; get out<br>
Operation.sem_op := -1; //reduce the semaphore count to
lock<br>
Operation.sem_num := 0; //signifies 0th semaphore<br>
Operation.sem_flg := IPC_EXCL; // fail if key exists<br>
Ret := semop(LockerS, @Operation,1);<br>
if Ret >= 0 then<br>
Break;<br>
end<br>
end else begin<br>
LastError := errno;<br>
LastErrorText := strerror(LastError);<br>
Memo1.Lines.Add(Format('semaphore locker not created
errno:%d-%s', [LastError, LastErrorText]));<br>
end<br>
<br>
<b>semget </b>always returns -1 with errno set to 2 (?) whatever
the contents of <b>SemKey</b> could be.<br>
<br>
What is wrong ?<br>
<br>
Antonio.<br>
<br>
</body>
</html>