As others said, you should be very wary of doing work in a signal handler. There is a
short list of async-signal safe functions. If you're calling anything outside that list, there is already potential for breakage even disregarding that caused by potential data structure corruption.
I would do as recommended, restructure your code to capture the signal and relay it outside the signal handler to be handled by the main thread of execution. You can use, for example, a pipe to put a byte on signaling something has been caught; since write is safe you can call it.
Even the pthread_mutex_lock is async-signal
unsafe. Outside of rolling your own async-signal safe locks using atomic variables, I can't suggest anything else. Not to mention that even if you properly protect the data structure, you're still limited in what you can do to it by the lack of safe functions you can call.