[c++-pthreads] Re: pthread_cancel and EH: let's try this again

Mark Mitchell mark at codesourcery.com
Fri Jul 15 07:29:05 UTC 2005


Jakub Jelinek wrote:
> On Fri, Jul 15, 2005 at 12:19:38AM -0700, Mark Mitchell wrote:
> 
>>Jakub Jelinek wrote:
>>
>>>On Thu, Jul 14, 2005 at 05:24:57PM -0700, Mark Mitchell wrote:
>>>
>>>
>>>>Why not just have two modes, controlled by an environment variable, 
>>>>link-time option, or run-time variable?  In the first mode, cancellation 
>>>>would not be an exception and nothing but pthread_cleanup_push'd code is 
>>>>run, and stack unwinding of all kinds is totally ignored.  In the second 
>>>>mode, cancellation would be an exception; nothing more, nothing less.
>>>
>>>
>>>There is big amount of code in Linux after a few past years that already
>>>has pthread_cleanup_{push,pop} internally implemented as a C++ object
>>>with a destructor.  So this is really not a workable option.
>>
>>Really?
> 
> <pthread.h> has:

Sorry, I didn't mean that I didn't believe you; it's just that my RHEL 3 
box doesn't have that, so I was slightly surprised.

That means that, as you say, you've committed to using an exception to 
implement thread cancellation.  So, now you get the semantics of 
exceptions -- including that they can be caught by "catch (...)".

-- 
Mark Mitchell
CodeSourcery, LLC
mark at codesourcery.com
(916) 791-8304



More information about the c++-pthreads mailing list