title: How to check in C Posix thread if someone is waiting on a shared semaphore?
body: <p>This is for exception handling scenario in a multi-threaded scenario. More than one threads are working in parallel on some shared resource locked under mutual exclusion whenever needed. If one thread faces an exception, can  I use sem_trywait to  check if some other thread is waiting on the semaphore and if I find some thread is waiting on a semaphore, will use a flag that exception has occurred and I will issue a sem_post so that waiting thread may unwait and check if some exception occurred before proceeding further. In case exception occurred, the other thread which was otherwise waiting will now proceed towards a graceful exit. Please suggest.
  My actual qs is: can I use sem_trywait?</p>