pthread conditions and process termination

后端 未结 3 1302
长情又很酷
长情又很酷 2021-01-12 14:55

I have a process-shared pthread condition (with associated mutex). What would happen if a process waiting on this condition (using pthread_cond_wait() or pthread_cond_timed

3条回答
  •  渐次进展
    2021-01-12 15:41

    It seems that the p2 process is waiting on the conditional variable eternally since the p1 process has no chance to send a notification being terminated by ctrl-c. As you and other people have already mentioned pthread conditional variable does not "know" about its original process termination.

    If you cannot use another inter process communication features and still insist on shared mutex and conditional variable, I would think about trapping the signal.

提交回复
热议问题