title: main process --> pthread --> fork --> lets the forked process run and kill main
body: <p><strong>Process A should start process B and then terminate. Process B should continue as an independent process</strong></p>
  <p>please have a little mercy on me - i am trying to educate myself and i like to learn more</p>
  <pre><code>int parallel_thread1;
  pthread_t thread1;
  
  static void *performer(void) {
      pid_t pid;
      pid = fork();
      if (pid &lt; 0)
          exit(EXIT_FAILURE);
  
      if (pid &gt; 0)            // if success then let the parent terminate
          exit(EXIT_SUCCESS);
  
      if (setsid() &lt; 0)
          exit(EXIT_FAILURE);
  
      pid = fork();
      if (pid &lt; 0)
          exit(EXIT_FAILURE);
  
      if (pid &gt; 0)
          exit(EXIT_SUCCESS);
  
      switch(pid)
      {
      case -1: // Fork() has failed
          perror (&quot;fork&quot;);
          break;
      case 0: // This is processed by the child
          system(&quot;/home/performerprocess/bin/performer&quot;);
          exit(EXIT_FAILURE);
          break;
  
      default: // This is processed by the parrent
          break;
      }
  
      return(0);
  
  }
  
  int main(int argc, char *argv[])
  {
   parallel_thread1 = pthread_create(&amp;thread1, NULL, &amp;performer, NULL);
   if(parallel_thread1 == 0)
     {
       pthread_detach(updateThread);
       usleep(500000);
      }
  
   ...
  
  puts(&quot;Process should already be terminated :(   I don't want to see this msg&quot;);
  return 0;
  }
  
  </code></pre>
  <p>please suggest a &quot;clean&quot; solution - thank you very much ;)</p>