From owner-freebsd-hackers Wed Jun 24 15:26:22 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id PAA15643 for freebsd-hackers-outgoing; Wed, 24 Jun 1998 15:26:22 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from coleridge.kublai.com (coleridge.kublai.com [207.96.1.116]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA15519 for ; Wed, 24 Jun 1998 15:25:39 -0700 (PDT) (envelope-from shmit@coleridge.kublai.com) Received: (from shmit@localhost) by coleridge.kublai.com (8.8.8/8.8.8) id SAA05477; Wed, 24 Jun 1998 18:22:46 -0400 (EDT) (envelope-from shmit) Message-ID: <19980624182243.37940@kublai.com> Date: Wed, 24 Jun 1998 18:22:43 -0400 From: Brian Cully To: John Birrell Cc: hackers@FreeBSD.ORG Subject: Re: Weirdness with pthreads in -current Reply-To: shmit@kublai.com References: <19980624031814.19037@kublai.com> <199806242106.HAA04775@cimlogic.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89i In-Reply-To: <199806242106.HAA04775@cimlogic.com.au>; from John Birrell on Thu, Jun 25, 1998 at 07:06:56AM +1000 X-Sender: If your mailer pays attention to this, it's broken. X-PGP-Info: finger shmit@kublai.com for my public key. Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 #include 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