Q: sem_wait() fails with error: success Trying to synchronize process on unix using semaphores, sem_wait() fails with error "success".
I have 3 process, each of which runs the same code:
while( sem_wait( &sem ) == -1 );
    if( errno != EINTR )
    {
        perror("Failed to lock semaphore");
    }
/* critical section */
while( sem_post( &sem ) < 0 )
    {
        perror("Failed to unlock semaphore");
    }

sem_init() and sem_destroy() are called in the parent process, before (and after) the child processes are created. The result is:
Failed to lock semaphore: Success
Failed to lock semaphore: Success
Failed to lock semaphore: Success

Is sem_wait() failing? and if it does, why does it say "success"?
