use of pointer to pointer in pthread_join function

342 views Asked by At
int pthread_join(pthread_t thread, void **retval);

According to the man page pthread_join should use a pointer to a pointer as argument to store the return value.I cant understand why its designed that way.Is it sufficient to use a pointer variable in that ?

2

There are 2 answers

1
µtex On

If I have understood your query clearly.. you should use like this..

pthread_t a_thread;
void *thread_result;
pthread_join(a_thread, &thread_result);
0
n. m. could be an AI On

The start routine you pass to pthread_create returns a value of type Foobar. I don't know what Foobar is, but if you want to capture that value in pthread_join, you have to pass a Foobar* in.

Now when I look at pthread_create documentation, I see that Foobar is actually void*. Hence pthread_join should accept void**.