QNX Developer Support
Wait on a semaphore, but don't block
#include <semaphore.h> int sem_trywait( sem_t * sem );
- A pointer to the sem_t object for the semaphore that you want to wait on.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The sem_trywait() function decrements the semaphore if the semaphore's value is greater than zero; otherwise, the function simply returns.
- The semaphore was successfully decremented.
- The state of the semaphore is unchanged (errno is set).
- The semaphore was already locked, so it couldn't be immediately locked by the sem_trywait() function.
- A deadlock condition was detected.
- Invalid semaphore descriptor sem.
- A signal interrupted this function.