Reputation: 1248
What baffles me is that pthread_mutex_lock
does not have E_INTR
as return value. Although pthread_cond_wait
can be spurious waken up and return 0, because of the while loop and Mesa monitor semantics, this is not a problem.
So if a process is blocked by pthread_mutex_lock
, and you send a signal to wake it up, after signal handler is executed, what will happen? Are there any mechanism to avoid this spurious wake up?
Upvotes: 0
Views: 46
Reputation: 213646
if a process is blocked by pthread_mutex_lock, and you send a signal to wake it up, after signal handler is executed, what will happen?
If the signal handler didn't invoke any async-signal unsafe operations, then after the handler returns, the process will continue waiting for the mutex.
If the signal handler did invoke an async-signal unsafe operation (e.g. unlocked the mutex), the behavior is undefined: anything can happen, including (but not limited to) crashing, blocking forever, appearing work "normally", etc. etc.
Upvotes: 1