[611] in Pthreads mailing list archive

home help back first fref pref prev next nref lref last post

Re: pthread_cancel and cleanup handlers

daemon@ATHENA.MIT.EDU (Craig Taverner)
Wed Mar 19 06:23:54 1997

Date: Wed, 19 Mar 1997 13:04:36 +0200 (SAT)
From: Craig Taverner <craig@hobbes.gh.wits.ac.za>
Reply-To: Craig Taverner <craig@hobbes.gh.wits.ac.za>
To: monty@analytikerna.se, pthreads@MIT.EDU
In-Reply-To: <199703121920.VAA19562@bitch.sci.fi>

> Any cancellation cleanup handlers that have been pushed and not yet
> popped are popped in reverse order in which they where pushed and then
> executed.
> 
> It seams that Solaris does wrong in this case.

It seems both solaris and linux do wrong.  Solaris fails to call the
cleanup handler from pthread_exit() inside the cleanup handler (bypassing
a serious bug in my code), but does call the cleanup handler when the
thread is cancelled with pthread_cancel.  Linux calls the cleanup handler
from the pthread_exit() function (causing recursive cleanup), which is
correct, while failing to call the cleanup handler when being cancelled.

Even worse, having cancelled a joinable thread under linux, I fail to join
with the thread.  Testing the pthread_attr for that thread shows it have
have an 'unknown' attribute after cancellation, while having a known
'joinable' attribute before.  The separate process associated with the
thread (under LinuxThreads) also no longer exists after cancellation, but
I would have expected it exit status to still be available to
pthread_join.

I have a few questions then about LinuxThreads:
1 - has anyone else seens this strange pthread cancellation behavior, and
any ideas on a fix? ( would really like to get the exit status of threads
that are cancelled)
2 - any know when LinuxThreads will have the same PID?  I'm worried about
running out of PID's with heavily multithreaded programs (amongst other
things).

Any comments?

Thanks, Craig

------
Duct tape is like the force.  It has a light side, and a dark side, and
it holds the universe together ...
                -- Carl Zwanzig

Craig Taverner
Structural Chemistry, University of the Witwatersrand, South Africa
tel:   +27-11-716-2290                fax: +27-11-716-3826
email: craig@hobbes.gh.wits.ac.za
www:   http://www.gh.wits.ac.za/craig




home help back first fref pref prev next nref lref last post