hi there, my first thread:
i'm using shared ipc-semaphores for multiple applications.
semget(key, 1, 0666 | IPC_CREAT);
gets makes a process create or share an existing sem. now, as several processes use one sem, who is going to destroy that sem? for closing the sem, i use
semctl(key, 0, IPC_RMID);
which works fine, but does not check if other processes still use it. at the moment, the first process which ends kills the sem, which makes all others produce errors.
i'd like only the *last* process living to kill the sem (not the owner, not the creator), all others should leave it alone.
Any inspiration? thx!