title: linux clone() function leads to weird compilation error, why?
body: <p>I've got a short program which is below, I tried to learn how "clone" function actually works.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;sched.h&gt;
  #include&lt;unistd.h&gt;
  #include&lt;sys/types.h&gt;
  extern int errno;
  int f(void*arg)
  {
  pid_t pid=getpid();
  printf("child pid=%d\n",pid);
  }
  char buf[1024];
  int main()
  {
  int ret=clone(f,buf,CLONE_VM|CLONE_VFORK,NULL);
  if(ret==-1){
      printf("%d\n",errno);
      return 1;
  }
  printf("father pid=%d\n",getpid());
  return 0;
  }
  </code></pre>
  
  <p>g++4.1.2 compiles it and say:</p>
  
  <pre><code>$g++ testClone.cpp
  /usr/bin/ld: errno: TLS definition in /lib64/libc.so.6 section .tbss mismatches non-TLS reference in /tmp/ccihZbuv.o
  /lib64/libc.so.6: could not read symbols: Bad value
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I also tried</p>
  
  <pre><code>g++ testClone.cpp -lpthread
  </code></pre>
  
  <p>Doesn't compile either. Why?</p>