title: pthread_t is initialised for thread it is defined in?
body: <p>I am using pthread_t to print out the pid of a thread that I manually create in C.  However, I print it before I create my new thread (passing it by ref as a parameter) and it prints a different value (presumably the thread that my main function is executing on).  I would have expected it to default to be 0 or unitialised.  Any ideas?
  Thanks, </p>
  
  <pre><code>#include &lt;fcntl.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #include &lt;pthread.h&gt;
  
  struct thread_info {    /* Used as argument to thread_start() */
      pthread_t thread_id;/* ID returned by pthread_create() */
  };
  
  static void *thread_1_start(void *arg) {
      struct thread_info *myInfo = arg;
      printf("Started thread id: %d\n", myInfo-&gt;thread_id);
      pthread_exit(0);
  }
  
  int main() {
      struct thread_info tinfo;
  
      int s;
      printf("Main thread id: %d\n", tinfo.thread_id);
      s = pthread_create(&amp;tinfo.thread_id,
          NULL, // was address of attr, error as this was not initialised.
          &amp;thread_1_start,
          &amp;tinfo);
      pthread_join(tinfo.thread_id,NULL);
  }
  </code></pre>
  
  <p>Actual output:</p>
  
  <pre><code>Main thread id: 244580352
  Started thread id: 245325824
  </code></pre>
  
  <p>Expected output:</p>
  
  <pre><code>Main thread id: // 0 or undefined
  Started thread id: 245325824
  </code></pre>