Date: Sun, 24 Aug 1997 04:31:15 -0400 (EDT) From: Bradley Dunn <bradley@dunn.org> To: freebsd-hackers@freebsd.org Subject: pthread_join question Message-ID: <Pine.BSF.3.96.970824041223.838A-100000@ns2.harborcom.net>
next in thread | raw e-mail | index | archive | help
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 <pthread.h> #include <stdio.h> #include <errno.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.970824041223.838A-100000>