Subj : Re: asynchronous cancel vs calling pthread_exit in signal handler To : comp.unix.programmer,comp.programming.threads From : Loic Domaigne Date : Tue Apr 26 2005 10:31 pm Hello Dave. > so what is the general rule? > (1) If I'm sure that the signal doesn't interrupt any > nonasync-signal-safe functions, can I call nonasync-signal-safe > function in the signal handler? quoted from Dave Butenhof: Technically, yes. But I wouldn't bet much on it, as it's hard to code and hard to test. It may be satisfying on some level to know that the reason your application fails is an IMPLEMENTATION bug rather than an APPLICATION bug; but your application still doesn't work. ;-) Furthermore, this guarantee helps you only if you know exactly what your thread will be doing at every instant in time. That is, essentially, that you're writing a monolithic embedded application and never calling any outside code with any signal unmasked. If you use the C or C++ runtime or threads, for example, any time you spend in those libraries is NOT safe against async signals; unless you have all your signals masked on each call. Hope this help, Loic. .