title: Why doesn't die in alarm signal handler kill the process?
body: <p>From How can I specify timeout limit for Perl system call?</p>
  
  <pre><code>eval { 
      local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required 
      alarm $timeout; 
      $nread = sysread SOCKET, $buffer, $size; 
      alarm 0; 
  }; 
  if ($@) { 
      die unless $@ eq "alarm\n";   # propagate unexpected errors 
      # timed out 
  } 
  else { 
      # didn't 
  } 
  </code></pre>
  
  <p>If a timeout happens, should <code>sub { die "alarm\n" };</code>  cause the end of a process. I guess I am not able to understand <code>die</code>. This <a href="http://www.cs.cf.ac.uk/Dave/PERL/node111.html" rel="nofollow">http://www.cs.cf.ac.uk/Dave/PERL/node111.html</a> says that "The die() function is used to quit your script and display a message for the user to read". However, in the case of the script above, the script will process the code in #timed out. Also sysread continues to work. Instead of sysread, I had a perl script that slept for 30 seconds. My timeout was set to 10 seconds. As expected, the code in #timed out is executed but the script continued to sleep.Any inputs appreciated</p>