Subj : Re: atexit handler: pthread_cancel, pthread_testcancel, pthread_join To : comp.programming.threads From : Joe Seigh Date : Thu Aug 18 2005 08:37 am Joe Seigh wrote: > > I think exit() just terminates all the threads so there are no threads > to cancel > or join. You should probably get EINVAL though unless something somewhere > says you can have undefined behavior. The core dump is probably from > the thread > id being invalid. Thread id's are opaque handles and on Linux appear to > be pointers > to thread local storage and you tend to get core dumps when no longer > valid thread > id's are dereferenced. > man exit says this > Threads terminated by a call to _Exit() or _exit() shall not invoke > their cancellation cleanup > handlers or per-thread data destructors. > > exit isn't a clean way to terminate threads so the obvious answer is > don't use it if you > want clean thread termination. > That's incorrect, I see that the man page for exit also says "The exit() function shall first call all functions registered by atexit()," so the atexit handlers will be guaranteed to be called before any threads are terminated by exit(). -- Joe Seigh When you get lemons, you make lemonade. When you get hardware, you make software. .