Garrett Cooper wrote:
Garrett Cooper wrote:
Garrett Cooper wrote:
Garrett Cooper wrote:
On Feb 7, 2007, at 1:51 PM, Steve Watt wrote:
In <[EMAIL PROTECTED]>,
<[EMAIL PROTECTED]> 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...
I asked this because I was short on time and so was the person
who asked me earlier. I'm going to try giving the pthread exit and
join a shot just to see whether or not this is true or not and then
I'll report my results to the list.
Thanks for the insight though--hopefully my results will yield a
solid positive or negative to this being a problem.
-Garrett
Under Suse Linux there were absolutely no errors when I tried to do
this. I'll post a code snippet later.
-Garrett
Ok, here's a link to my code:
http://students.washington.edu/youshi10/posted/thread_test.c
My results (FreeBSD):
[EMAIL PROTECTED] /home/gcooper]# ./tt
Thread join detached
Thread kill detached
Joined thread yielded error code: 2
Trying to join the already joined thread yields error code: 0
My results (Suse Linux):
# ./tt
Thread join detached
Thread kill detached
Joined thread yielded error code: 0
Trying to join the already joined thread yields error code: 0
That was sure interesting.. is it supposed to error out or was it the
remnant of an old error call?
Probably the latter, but I was just curious..
-Garrett
Actually, now that I think about it the calls I made with ps in the
program are valid for Linux but not for FreeBSD (they're for getting
thread listings). Hence error code 2.
From intro(2):
2 ENOENT No such file or directory. A component of
a specified pathname did not exist, or
the pathname was an empty
string.
Didn't think that a bad command would return errno=2 though..
-Garrett
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"