I have a double linked list protected by a pthread mutex. How can I access this list properly from a signal handler? (Here, the signal handler is the producer and some other code (thread) is the consumer.)
1.) I do not need to mutex_lock the list because the signal handler is the only part of the entire program that can access the list during the signal processing.
2.) But what happens if the signal handler e.g. adds something to the list and one of the other threads was currently accessing the linked list when the signal was raised? In this case I think that the code might crash when the signal handler returns (because of the list modification in the signal handler, which is not detected by the thread currently accessing the list).
Any idea on how to deal with this scenario?