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.

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to