The function header for pthread_create looks like this:
int pthread_create(pthread_t * thread,
const pthread_attr_t * attr,
From the documentation for pthread_create:
The thread is created executing
start_routinewithargas its sole argument. If thestart_routinereturns, the effect is as if there was an implicit call topthread_exit()using the return value ofstart_routineas the exit status. Note that the thread in whichmain()was originally invoked differs from this. When it returns frommain(), the effect is as if there was an implicit call toexit()using the return value ofmain()as the exit status.
And pthread_exit:
The
pthread_exit()function terminates the calling thread and makes the valuevalue_ptravailable to any successfuljoinwith the terminating thread.
So if you do a pthread_join on a thread, the pointer it returns is passed back to the joining thread, allowing you to transmit information from the dying thread to another, living thread.
From the spec:
If the
start_routinereturns, the effect is as if there was an implicit call topthread_exit()using the return value ofstart_routineas the exit status.