Signal processing

We have written a deamon which have many threads.
We are registering for the SIGTERM and trying to close main thread in this signal handling. Actually these are running on Mac OS X ( BSD unix). When we are unloading the deamon with command launchctl, it's sending SIGTERM signal to our process but it's crashing while we are going to close our main thread. It's crashing when oing to access some static data. I like to know, how SIGTERM are sending by the OS and once we finished the signal function and if still there is sosme more threads then what happened. My process should crashed or exited smoothly. Our process is crashing some time.

This shouldn't happen. Your program is still running when the SIGTERM signal is sent to it, and if you are correctly catching the signal, there shouldn't be any problem. Now, when you say you are going to access some "static data", do you mean data declared globally? such as in

static some_type some_variable;

Or do you mean something else? Perhaps you are trying to access data declared to be static variables within a thread. Hrm?