title: Use system() to create independent child process
body: <p>I have written a program where I create a thread in the main and use <code>system()</code> to start another process from the thread. Also I start the same process using the <code>system()</code> in the main function also. The process started from the thread seems to stay alive even when the parent process dies. But the one called from the main function dies with the parent. Any ideas why this is happening.</p>
  
  <p>Please find the code structure below:</p>
  
  <pre><code>void *thread_func(void *arg)
  {
       system(command.c_str());        
  }
  
  int main()
  {
      pthread_create(&amp;thread_id, NULL, thread_func, NULL);
      .... 
      system(command.c_str());
      while (true)
      {
          ....
      }
      pthread_join(thread_id, NULL);
      return 0;
  }
  </code></pre>