Subj : Deadlock (pthread) in signal handler To : comp.programming.threads From : szehau Date : Thu Apr 28 2005 09:02 am I understand that calling a async-signal-safe function in signal handler can easily cause a deadlock. In my program, in certain condition it need to call exit() in signal handler. The exit() function will actually call other registered cleanup functions from other library such as DB2. The program hangs when receive a signal interrupt and goes into a race condition (because of pthread try to acquire a mutex lock in malloc). My question is: Is there any way that I can check whether the program is currently hold a mutex lock (in malloc() or free())? I need this detection to enable my program to retry on exit when there is no active lock on the current process. FYI, I'm using Linux, GCC 3.2, DB2 8.1.5 Thanks .