previous | start | next

Example

What does this code do if it is "cancelled while in the pthread_cond_wait call?

Does the thread leaving the mutex locked?

Does the cleanup try to unlock a mutex that is not locked?

    1   pthread_mutex_lock(&m);
    2   pthread_cleanup_push(pthread_mutex_unlock, &m);
    3   while(should_wait)
    4     pthread_cond_wait(&cv, &m);
    5   
    6   // . . . (code containing other cancellation points)
    7   
    8   pthread_cleanup_pop(1);


previous | start | next