bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: exceptions


From: Federico Montesino Pouzols
Subject: Re: exceptions
Date: Wed, 10 Jul 2002 00:42:21 +0200 (CEST)

> Hi all!
>
> Can a parent thread  catch a exception thrown from another thread, like
> this?
>
> main()
> {
> ...
>       try {
>               thread->start(); //throw a exception
> ...
>       }
>       catch(const exception& e) {
> ...
>       }
> ...
> }
>
>

  Ummm, I think this is not possible in C++. What happens when an
exception is thrown inside a thread in which there is no
correspoding exception handler (catch) is the same as when the
exception is thrown in the main thread: program termination.
Signal SIGABRT in POSIX systems. Is seems that in CC++ you can
"catch" SIGABRT redefining PosixThread::onException().

  If you want a parent to know a thread has raised a certain
exception, perhaps you could try to catch that exception inside
the children and then use signals to communicate through threads.
The children would use signalParent() to "throw" the signal to the
parent, and then the parent would use onSignal() to "catch" the
signal.


> Marcelo Dalmas
> BRASMAP Sistemas
> www.brasmap.com.br
> Fone/Fax: (48) 333-2218 ramal 2114
>






reply via email to

[Prev in Thread] Current Thread [Next in Thread]