title: What does exactly the "status" in pthread_join represent and how to query it
body: <p>I'm wondering what exactly the "status" parameter in the pthread_join is for</p>
  
  <pre><code>int pthread_join(pthread_t thread, void **status);
  </code></pre>
  
  <p>I'm trying to make use of it but I cannot understand what exactly does it represent.
  According to the documentation</p>
  
  <blockquote>
    <p>status </p>
  
  <pre><code>Is the location where the exit status of the joined thread is stored.
  </code></pre>
    
    <p>This can be set to NULL if the exit
    status is not required.</p>
  </blockquote>
  
  <p>OK. That sounds nice. How do I use it? I've looked at some examples but I cannot 
  get the hang of it(and some examples are plain wrong in using it). So I did go to 
  the source. In the glibc implementation I found the following test for pthread_join:</p>
  
  <pre><code>...
  pthread_t mh = (pthread_t) arg;
  void *result;
  ...
  if (pthread_join (mh, &amp;result) != 0)
  {
    puts ("join failed");
    exit (1);
  }
  
  here follows the WTF moment ...
  
  if (result != (void *) 42l)
  {
    printf ("result wrong: expected %p, got %p\n", (void *) 42, result);
    exit (1);
  }
  </code></pre>
  
  <p>So the value of the result(which is an address) should be 42?? Is this something global 
  at the library level, because I could not find anything specific in the <a href="http://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/tst-join1.c;h=95a78ba0b546303801591021923a7f77656a2909;hb=master" rel="nofollow noreferrer">test</a>?</p>
  
  <p>EDIT: it seems <a href="https://stackoverflow.com/questions/3692591/return-versus-pthread-exit-in-pthread-start-functions">this question</a> provides info related to what I asked</p>