title: How can I kill Perl 'system' calls when the main script is killed?
body: <p>Pervious answers to this questions have focused on forks: </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/360201/kill-background-process-when-shell-script-exit">kill background process when shell script exit</a></li>
  <li><a href="https://stackoverflow.com/questions/284325/how-to-make-child-process-die-after-parent-exits#285134">How to make child process die after parent exits?</a></li>
  <li><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>
  
  <p>For this question, I'm just asking about calls to the 'system' function.</p>
  
  <p>Say I have a script called <em>sleep.pl</em>:</p>
  
  <pre><code>use strict;
  use warnings;
  sleep(300);
  </code></pre>
  
  <p>I then have a script called <em>kill.pl</em></p>
  
  <pre><code>use strict;
  use warnings;
  system("sleep.pl");
  </code></pre>
  
  <p>I run kill.pl and using ps I find the process id of kill.pl and kill it (not using kill -9, just normal kill)</p>
  
  <p>sleep.pl is still sleeping.</p>
  
  <p>I imagine the solution to my question involves a SIG handler, but what do I need to put into the handler to kill the child process?</p>