Boost logo

Boost :

Subject: Re: [boost] at_thread_exit() never getting called
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-10-29 04:49:08


"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
>>>> hook
>>>> 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?

No.

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.

Anthony

-- 
Author of C++ Concurrency in Action | http://www.manning.com/williams
just::thread C++0x thread library   | http://www.stdthread.co.uk
Just Software Solutions Ltd         | http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk