Possible Duplicate:
Interprocess semaphores sometimes not working as expected
In my application, I notice that a semaphore of type sem_t sometimes become 1 from 0 without executing sem_post. How come? What can cause this? The semaphore is used for inter-process communication and you can look at the code here.
The code that you are linking to doesn’t capture the return values from the
sem_tcalls. If you look in the manual you can see that e.gsem_waitcan return prematurely, so-called spurious wakeups.Always check the return codes of these functions. If the return is
-1checkerrnofor the corresponding error and decide if it is a transient error. If so, iterate.