Is it possible to emulate the System V primitive semctl(semid,0,GETPID,0) in an environment using POSIX semaphores?
If it is not possible, I’m looking for a method to know who has done the last operation on a semaphore, I’m going to explain better…
I’m developing a UDP server with preforked children. The father handles SIGCHLD to respawn a dead child. If a child dies in the critical section (namely it has not yet done the sem_post) the father has to recognize this situation and unlock the semaphore.
What you want cannot be done. You could emulate the behavior partly by writing your own semaphore based on POSIX robust mutexes (but it would have some disadvantages like not being async-signal-safe), or you could just use a robust mutex instead of a semaphore to begin with.