title: How to make child process die after parent exits?
body: <p>Suppose I have a process which spawns exactly one child process. Now when the parent process exits for whatever reason (normally or abnormally, by kill, ^C, assert failure or anything else) I want the child process to die. How to do that correctly?</p>
  
  <hr>
  
  <p>Some similar question on stackoverflow:</p>
  
  <ul>
  <li>(asked earlier) <a href="https://stackoverflow.com/questions/269494/how-can-i-cause-a-child-process-to-exit-when-the-parent-does">How can I cause a child process to exit when the parent does?</a></li>
  <li>(asked later) <a href="https://stackoverflow.com/questions/395877/are-child-processes-created-with-fork-automatically-killed-when-the-parent-is-k">Are child processes created with fork() automatically killed when the parent is killed?</a></li>
  </ul>
  
  <hr>
  
  <p>Some similar question on stackoverflow for <strong>Windows</strong>:  </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/53208/how-do-i-automatically-destroy-child-processes-in-windows">How do I automatically destroy child processes in Windows?</a>  </li>
  <li><a href="https://stackoverflow.com/questions/3342941/kill-child-process-when-parent-process-is-killed">Kill child process when parent process is killed</a></li>
  </ul>