
cowwoc wrote:
Peter Dimov-5 wrote:
The at_thread_exit hooks are invoked in the context of the thread. When exit is called, the threads are executing something, and it is not possible to make them stop whatever they are doing in order to execute the at_thread_exit hooks (and it would be a bad idea were it possible, because the thread state could be inconsistent and cause a crash in the hook.)
Peter,
Are you saying that if I register shutdown hooks for threads 1, 2 and 3 and invoke exit() from thread 3 the current behavior of at_thread_exit() would cause the shutdown hooks to all get invoked by thread 3 while thread 1 and 2 are still executing?
I'm not sure what the current behavior is, but in this scenario, no hooks should be executed. I think that this is consistent with how TSD destructors work under POSIX, but I can't test this at the moment.