title: Signal handling in a shell script
body: <p>Following is a shell script (myscript.sh) I have:</p>
  
  <pre><code>#!/bin/bash
  
  sleep 500 &amp;
  
  Aprogram arg1 arg2  # Aprogram is a program which runs for an hour.
  
  echo "done"
  </code></pre>
  
  <p>I launched this in one terminal, and from another terminal I issued <em>'kill -INT 12345'</em>. 12345 is the pid of myscript.sh.</p>
  
  <p>After a while I can see that both myscript.sh and Aprogram have been dead. However <em>'sleep 500 &amp;'</em> is still running.</p>
  
  <p>Can anyone explain why is this behavior? </p>
  
  <p>Also, when I issued SIGINT signal to the <em>'myscript.sh'</em> what exactly is happening? Why is <em>'Aprogram'</em> getting killed and why not <em>'sleep'</em> ? How is the signal INT getting transmitted to it's child processes?</p>