From owner-freebsd-hackers Sun Aug 24 01:31:18 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id BAA22320 for hackers-outgoing; Sun, 24 Aug 1997 01:31:18 -0700 (PDT) Received: from ns2.harborcom.net (root@ns2.harborcom.net [206.158.4.4]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id BAA22315 for ; Sun, 24 Aug 1997 01:31:16 -0700 (PDT) Received: from localhost (bradley@localhost) by ns2.harborcom.net (8.8.7/8.8.5) with SMTP id EAA03834 for ; Sun, 24 Aug 1997 04:31:15 -0400 (EDT) Date: Sun, 24 Aug 1997 04:31:15 -0400 (EDT) From: Bradley Dunn X-Sender: bradley@ns2.harborcom.net Reply-To: Bradley Dunn To: freebsd-hackers@freebsd.org Subject: pthread_join question Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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? Here is the code from the book: #include #include #include int main (int argc, char *argv[]) { pthread_t thread; int status; status = pthread_join (thread, NULL); if (status != 0) fprintf (stderr, "error %d: %s\n", status, strerror (status)); return status; } The output is: error -1: Unknown error: -1 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). 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? PS -- Please CC me as I am not on -hackers. Thanks, pbd -- The more laws and order are made prominent, the more thieves and robbers there will be. -- Lao Tsu