Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

shared ipc_semaphores: who destroys?

hi there, my first thread:

i'm using shared ipc-semaphores for multiple applications.
creating with
[code]
semget(key, 1, 0666 | IPC_CREAT);
[/code]
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
[code]
semctl(key, 0, IPC_RMID);
[/code]
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!

Comments

  • urmeleurmele Member Posts: 5
    what i need is a kind of "nattach" info for semaphores, like there is for shared memory when calling "ipcs" on console.
Sign In or Register to comment.