From: Darryl Green (green_at_[hidden])
Date: 2002-08-25 19:13:42


> -----Original Message-----
> From: Alexander Terekhov [mailto:terekhov_at_[hidden]]
>
> Well, it "can be done" (initial/main thread including, BTW):
>
> http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/EDC
> LB120/5.1.55
> (5.1.55 set_terminate() -- Register a Function for terminate())
>
> "....
> Note that the function registered for terminate() must terminate
> execution of the program without returning to its caller().

snip...

>
> Well, this stuff aside, consider that pthread_exit() is nothing
> but a) store the argument in the thread object for POSIX joinable
> thread and b) throw "thread_exit" exception to unwind the stack;
> call POSIX/C thread cleanup handlers, etc.
>
> But "stack unwinding" (to the extent that there can be >>NO<<
> try scope at all; see the definition of "stack unwinding" term)
> explicitly PROHIBITED in all but one terminate() cases:
>
> ISO/IEC 14882:1998(E), Pg. 299
>
> "In such cases,
>
> void terminate();
>
> is called (18.6.3). In the situation where no matching handler
> is found, it is implementation-defined whether or not the stack
> is unwound before terminate() is called. In all other situations,
> the stack shall not be unwound before terminate() is called."
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Doesn't this only define what happens before terminate() is called? I don't
see the conflict between this and the use of pthread_exit() (or
"equivalent") in a terminate handler in order to get the desired(?) result
of unwinding then terminating the thread?

Regards
Darryl.