[prev in list] [next in list] [prev in thread] [next in thread]
List: hpux-cxx-dev
Subject: Re: CXX-DEV: How to know a thread aborted?
From: Matthew Collins <collins () hpsgns1 ! sgp ! hp ! com>
Date: 2000-09-21 6:25:40
[Download RAW message or body]
Fu Ning wrote:
> Thanks a lot !
> But in the case 4&5,can I prevent the whole
> application from terminating ? I need to do some necessary
In the case of 4 and 5 you may find it very tricky to stop the
whole process from terminating safely and it is probably not
a very good idea to find out how to just terminate the thread
without terminating the rest of the process. For example
calling pthread_exit from within a signal handler would be
a very very bad idea.
I would only consider 1, 2 and 6 as possible viable abnormal
thread terminations and I've suggested two ways to detect
termination already.
>
> works after a thread terminated, and I don't want to disturb
> the thread from time to time by pthread_kill.How can I get to
If you issue a pthread_kill with signal 0 it wont disturb the
thread, all it does is check that the thread exists (ie check that
you could send a signal to the thread if you wanted to). I
wouldn't recommend the use of pthread_kill for this use as the
need to poll more often than not reflects a design flaw.
Matthew
>
> know that the thread has aborted?
>
> Best regards
>
> On Thu, 21 Sep 2000 12:32:06 +0800
> Matthew Collins <collins@hpsgns1.sgp.hp.com> wrote:
>
> > Depends on what you define as abnormal termination:
> >
> > 1) something cancels the thread,
> > 2) the thread calls pthread_exit,
> > 3) something calls pthread_kill,
> > 4) the thread calls exit/_exit/abort,
> > 5) the thread has an access violation/divide by zero etc
> > (ie SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGSYS),
> > 6) the thread returns from the start up function,
> > 7) the thread mysteriously disappears for no reason.
> >
> > In the case of 4&5 your whole application will be terminated, pretty easy to \
> > detect :-).
> > For 3 if this results in the thread being terminated (because the signal is not \
> > being handled and its default action is to terminate) then all threads will be \
> > terminated. The same applies to kill.
> > for 1&2&6 you could setup a cancellation handler (pthread_cleanup_push) or you \
> > could use thread specific data cleanup handler (pthread_key_create, \
> > pthread_setspecific etc).
> > In the case of 7 your problems are bigger than just worrying how to detect it :-)
> >
> > If you want to check if a thread is still around you could use pthread_kill with \
> > signal 0.
> > Matthew
> >
> >
> > Fu Ning wrote:
> >
> > > Hi!
> > > We want to develop a multi-thread process.
> > > How can we recognize a thread which is
> > > aborted abnormally ?
> > >
> > > best regards
_________________________________________________________________
To leave this mailing list, send mail to majordomo@cxx.cup.hp.com
with the message UNSUBSCRIBE cxx-dev
_________________________________________________________________
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic