Soumya Koduri [skod...@redhat.com] wrote: > > I thought pthread_exit() always returns a pointer which gets assigned to > retval of pthread_join(). I assume this is the flow -->
pthread_exit() does take a "void *", since it is "void *", it is up to you whether to really pass some pointer or some "casted" integer. In fact, PTHREAD_CANCELED is actually ((void *) -1) > pthread_join (thread, void **retval_join) > > pthread_exit (void *retval_exit) > > On exit, > *retval_join = retval_exit; > > I tried a sample program as per your suggestion. > > int ret1; > pthread_join (thread, (void **)&ret1); > > int ret2 = 1; > pthread_exit (&ret2); > > After pthread_join, ret1 has address of ret2 instead of its value. > i.e, this led to > ret1 = &ret2; > > Please correct me if I am missing something. Had you used pthread_exit((void*)ret2) or better pthread_exit((void*)1), ret1 would have the integer 1. This seems to be the standard practice. If you really want to pass a pointer to pthread_exit(), make sure that the thread that called pthread_join() will be able to access such memory. Too much hassle, that is why most people just cast integers if they just need integer returns. It is up to you but I feel that the code gets unnecessarily complicated by returning a real pointer from the upcall thread. Regards, Malahal. ------------------------------------------------------------------------------ _______________________________________________ Nfs-ganesha-devel mailing list Nfs-ganesha-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel