
21 Dec
2010
21 Dec
'10
3:38 p.m.
Viatcheslav.Sysoltsev wrote: ...
void tf() { printf("thread\n"); sleep(1); pthread_exit(NULL); }
pthread_exit in glibc/NPTL causes a "forced unwind" that is almost like a C++ exception, but not quite. (And its semantics probably have changed since last I looked.) Either way, a catch(...) clause that calls terminate(), as in the earlier version of Boost, or no catch clause at all, as in the later ones, should cause exactly the behavior you describe. Moving the cleanup code into a destructor should work on Linux. It won't on Mac OS X, for example, where pthread_exit unwinds without calling C++ destructors, as far as I know. But then you'd have other problems too. :-)