title: Raw Clone system call
body: <p>I am trying to use the raw clone system, but I could not find any proper documentation. 
  I tried to write a small program to try it, but this ends up with a segmentation fault. </p>
  
  <p>I cannot understand where I am wrong. </p>
  
  <p>here is the small application : </p>
  
  <pre><code>define STACK_SIZE 0x10000
  define BUFSIZE 200
  
  #define _GNU_SOURCE
  
  void hello (){
      fprintf(stderr,"Hello word\n"); 
      _exit(0); 
  }
  
  
  int main()  
  {
  
  int res; 
  void *stack = mmap(0, STACK_SIZE, PROT_READ|PROT_WRITE,
                         MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
    pid_t ptid, tid; 
  
    printf("Stack %p\n", stack + STACK_SIZE);
    memset(stack, 0, STACK_SIZE); 
  
    res= syscall(SYS_clone,CLONE_SIGHAND|CLONE_FS|CLONE_VM|CLONE_FILES,stack + STACK_SIZE, &amp;tid,&amp;ptid,NULL );
  
    if (!res)
        hello(); 
  
    printf("Clone result %x\n", res); 
    waitpid(-1, NULL, __WALL); 
  
   return 0; 
  }
  </code></pre>