Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 7 Feb 2007 21:51:30 +0000 (UTC)
From:      Steve Watt <steve.removethis@Watt.COM>
To:        hackers@freebsd.org
Subject:   Re: Trying to join an already exited pthread
Message-ID:  <eqdhl2$1tmb$1@wattres.Watt.COM>
References:  <Pine.LNX.4.43.0702071314560.22034@hymn08.u.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
In <Pine.LNX.4.43.0702071314560.22034@hymn08.u.washington.edu>,
 <youshi10@u.washington.edu> wrote:
>Just wondering:
>
>If I was to try and join a pthread that already exited, would there be an error
>message output and/or errno set to an error value, or would a system hang?

Was the thread created with detach state set PTHREAD_CREATE_DETACHED or
PTHREAD_CREATE_JOINABLE?  If it was PTHREAD_CREATE_JOINABLE, has the
thread already been joined?

You should be able to join a thread that was created joinable, only once.
If you join it again, or join a thread that was created detached, the
results are unspecified in POSIX.  There is an error status that may
be returned, but it may do other bad things to your system.

Note that pthread_join doesn't set errno; it returns an error value
directly.  I would never expect the system to hang, though the application
might.  If your application is hanging, make sure that you're not trying
to call pthread_join from within a signal handler.

>It this variable on Unix OSes?

That the results are unspecified?  No.  What "unspecified" means?
Absolutely.
-- 
Steve Watt KD6GGD  PP-ASEL-IA          ICBM: 121W 56' 57.5" / 37N 20' 15.3"
 Internet: steve @ Watt.COM                      Whois: SW32-ARIN
   Free time?  There's no such thing.  It just comes in varying prices...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?eqdhl2$1tmb$1>