Reputation:
How do I cause a thread to respond to pthread_cancel()
if it is blocked on a sem_wait()
?
Upvotes: 1
Views: 611
Reputation: 21175
You can set a signal handler, let's says for SIGUSR1, for the thread that will be blocking then, from another thread, you call pthread_cancel(tid)
and pthread_kill(tid, SIGUSR1)
. The thread will be canceled once sem_wait()
is interrupted by the signal.
Upvotes: 2