From owner-freebsd-hackers Sun Aug 24 19:13:43 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id TAA07429 for hackers-outgoing; Sun, 24 Aug 1997 19:13:43 -0700 (PDT) Received: from ocean.campus.luth.se (ocean.campus.luth.se [130.240.194.116]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id TAA07422 for ; Sun, 24 Aug 1997 19:13:40 -0700 (PDT) Received: (from karpen@localhost) by ocean.campus.luth.se (8.8.5/8.8.5) id EAA25202; Mon, 25 Aug 1997 04:20:22 +0200 (CEST) From: Mikael Karpberg Message-Id: <199708250220.EAA25202@ocean.campus.luth.se> Subject: Re: pthread_join question In-Reply-To: from Bradley Dunn at "Aug 24, 97 04:31:15 am" To: bradley@dunn.org Date: Mon, 25 Aug 1997 04:20:22 +0200 (CEST) Cc: freebsd-hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL31H (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk According to Bradley Dunn: > Hi, > > I just bought _Programming with POSIX Threads_ by Butenhof so I could > learn a little bit about threads. I have a question about pthread_join in > FreeBSD. It seems from looking at the source in > src/lib/libc_r/uthread/uthread_join.c > and from trying the test code on page 32 in the book that pthread_join > will always return -1 if an error occurs. The book says that Pthreads > doesn't use errno and returns the error directly. Can someone help me > understand this better? [...] > If I modify the code so that it checks errno, I find that errno is > indeed ESRCH (and the source for pthread_join seems to indicate this is > normal behavior). >From the only reference I have available (Solaris man page): RETURN VALUES If successful, both pthread_join() and thr_join() would return 0; otherwise, an error number is returned to indicate the error. Seems like you're right. Then I guess libc_r has a bug. :-) Try doing a send-pr with the problem. Maybe check the cvs online for the last few commits, and mail the person that seem to be most responsible for libc_r and tell him you have done a send-pr, too. :-) > Oh, and another quick question. I compiled the program using: > cc -Wall -othread_error thread_error.c -lc_r > Is the '-lc_r' the correct way to get the thread functions linked in? I really have no idea, but since no one else seem to have answered.. I think I saw a commit adding -thread or -threads option... Try: cc -Wall -threads -othread_error thread_error.c or cc -Wall -thread -othread_error thread_error.c And see if it works :-) > PS -- Please CC me as I am not on -hackers. Done. /Mikael