How do I recover a semaphore when the process that decremented it to zero crashes?
问题 I have multiple apps compiled with g++, running in Ubuntu. I'm using named semaphores to co-ordinate between different processes. All works fine except in the following situation: If one of the processes calls sem_wait() or sem_timedwait() to decrement the semaphore and then crashes or is killed -9 before it gets a chance to call sem_post() , then from that moment on, the named semaphore is "unusable". By "unusable", what I mean is the semaphore count is now zero, and the process that should