What happens when child thread crash and main wait for join?
<p>In the following program I created a <code>pthread_t</code> thread1 which crash in function <code>func()</code> . I am interested in what exactly happened for <code>pthread_join</code> command in <code>main()</code> .</p>

<p>I ran below program and in exited normally by printing "complete". I dont know why?</p>

<pre><code>#include &lt;iostream&gt; 
#include &lt;string&gt; 
#include &lt;vector&gt; 
#include &lt;map&gt; 
#include &lt;cstring&gt; 
#include &lt;climits&gt; 
#include &lt;cstdio&gt; 
#include&lt;pthread.h&gt;
#include &lt;stdlib.h&gt;
using namespace std; 

void* func(void *data)
{
    cout&lt;&lt;"Calling func"&lt;&lt;(long)(data)&lt;&lt;endl;
    int *a;
    cout&lt;&lt;a[2]&lt;&lt;endl;
    pthread_exit(0);
}

int main( )
{ 
    pthread_t thread1;
    pthread_create(&amp;thread1, 0 , &amp;func, (void*)2);
    pthread_join(thread1, NULL);
    cout&lt;&lt;"complete"&lt;&lt;endl;

}
</code></pre>