Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a signal caught if a thread is waiting on a mutex?

I have a thread blocked on a mutex. The application also has custom signal handlers, set using sigaction. If the thread that receives a catchable signal is blocked on a mutex, will the signal handler be called, or will it be blocked until the mutex is released?

like image 366
Joe Avatar asked Mar 18 '23 22:03

Joe


1 Answers

Most probably it will depend on implementation, in pthread for example signal handler will be executed and then thread will wait for mutex upon handler return:

man pthread_mutex_lock

If a signal is delivered to a thread waiting for a mutex, upon return from the signal handler the thread shall resume waiting for the mutex as if it was not interrupted.

like image 134
Slava Avatar answered Apr 01 '23 07:04

Slava