Subj : Re: Deadlock (pthread) in signal handler To : comp.programming.threads From : John Hickin Date : Thu Apr 28 2005 05:08 pm "Low Sze Hau" wrote in message news:d8de876f.0504280702.5edc5991@posting.google.com... > I understand that calling a async-signal-safe function in signal > handler can easily cause a deadlock. Most of the time I'd assume that such functions are OK to call in a signal handler. > > In my program, in certain condition it need to call exit() in signal OK, exit() is NOT async signal safe. > handler. The exit() function will actually call other registered > cleanup functions from other library such as DB2. The program hangs precisely because of what you just mentioned. > when receive a signal interrupt and goes into a race condition > (because of pthread try to acquire a mutex lock in malloc). > You can call _exit(). Your program has to cope with a dirty kill anyway (i.e., kill -KILL your-pid). The besy way is to avoid complicated cleanup. Regards, John. .