Date: Wed, 24 Jun 1998 18:22:43 -0400 From: Brian Cully <shmit@kublai.com> To: John Birrell <jb@cimlogic.com.au> Cc: hackers@FreeBSD.ORG Subject: Re: Weirdness with pthreads in -current Message-ID: <19980624182243.37940@kublai.com> In-Reply-To: <199806242106.HAA04775@cimlogic.com.au>; from John Birrell on Thu, Jun 25, 1998 at 07:06:56AM %2B1000 References: <19980624031814.19037@kublai.com> <199806242106.HAA04775@cimlogic.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jun 25, 1998 at 07:06:56AM +1000, John Birrell wrote:
> [ This should have been sent to -current, not -hackers ]
I sent it to hackers because I didn't know if it was a real problem or
just me misunderstanding something. :-)
> Brian Cully wrote:
> POSIX says that pthread_join() returns zero if no error, otherwise an
> error number is returned. It doesn't touch errno because it is not supposed
> to. 8-)
Yah, I re-read the man pages and realized I jumped to conclusions because
the errors began with E. :-)
> > This is -current from 28-May-1998, BTW.
>
> Do you have a small test program that exhibits this problem?
Yep, you can find it below.
What's strange is that if I remove the `return NULL' statement in
thread_func() I always get ESRCH, but with it there I only get ESRCH when
the sleep() call exists.
This may (and probably is) some drain-bamage on my part, but the
behaviour is certainly weird enough that I think that there's some kind
of bug somewhere in the thread code. :-)
[SNIP]
#include <pthread.h>
#include <stdio.h>
void *
thread_func(void *arg)
{
printf("\tIn thread_func.\n");
sleep(2);
printf("\tLeaving thread_func.\n");
pthread_exit(NULL);
return NULL;
}
int
main(int argc, char *argv[])
{
int rc;
pthread_t thread_id;
printf("Creating thread.\n");
rc = pthread_create(&thread_id, NULL, thread_func, NULL);
if (rc) {
fprintf(stderr, "Error: couldn't create thread: %s.\n",
strerror(rc));
return 1;
}
printf("Joining thread.\n");
rc = pthread_join(thread_id, NULL);
if (rc) {
fprintf(stderr, "Error: couldn't join with thread: %s.\n",
strerror(rc));
return 1;
}
return 0;
}
[SNIP]
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980624182243.37940>
