Subject: Re: [boost] [Boost-users] at_thread_exit() never getting called
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-10-29 09:13:00
----- Original Message -----
From: "Anthony Williams" <anthony.ajw_at_[hidden]>
Sent: Thursday, October 29, 2009 9:49 AM
Subject: Re: [Boost-users] at_thread_exit() never getting called
> "vicente.botet" <vicente.botet_at_[hidden]> writes:
>>>> cowwoc wrote:
>>>>> I am registering boost::this_thread::at_thread_exit() against one of my
>>>>> threads. When the main thread exits using "return 0" the at_thread_exit
>>>>> never gets invoked. Is this normal?
> If you call exit() then thread exit handlers are not called. "return 0"
> in main() is the same as calling exit(0), so thread exit handlers are
> not called.
>> Anthony, I've see that you have started to integrate the patch for the
>> thread attributes. Do you plan to integrate this patch also?
> If you call pthread_exit(0) from main() then thread exit handlers *will*
> be called. Of course, this doesn't exit the program until all other
> threads have terminated, whereas "return 0" kills the other threads.
Unfortunately, after rereading the patch I proposed, I recognize the patch don't works if there are other external threads in the programm as in patch stores only the last external thread context.
Calling pthread_exit(0) on a pthread thread is natural, but the main thread is no created as a pthread, so this call is not portable. Do you think that we need a portable function boost::exit that will call to pthread_exit?
With the current implementation we don't have any error when we call at_thread_exit on an external thread. This has as consequence that the destructors of the TSS are not called. This is a severe restriction from my point of view.
Do you have a portable solution?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk