Hey y'all, with enough trial and error I found something that works for me.  The key 
is to forget about using 'die', and define an empty handler instead:

sub synchronize {

 eval {
  local $SIG {ALRM} = sub {};
  print $writeme "PERL -e \"print kill (SIGALRM, $pid)\"\n";
  sleep;
 };

 sleep 1; # to let the output from the inner Perl get printed before we go on.

} # end sub synchronize

Defining an empty handler for a signal, it turns out, is not at all the same thing as 
ignoring the signal: the empty handler does cause exit from the sleep.  

If not using 'die', there's no need to use 'eval', either.  The following works as 
well:

sub synchronize {

  local $SIG {ALRM} = sub {};
  print $writeme "PERL -e \"print kill (SIGALRM, $pid)\"\n";
  sleep;

  sleep 1; # to let the output from the inner Perl get printed before we go on.

} # end sub synchronize

So it looks like I can go about my business.  But I've still got a shiny new sixpence 
for anyone who can tell me why the version with 'die' behaved so strangely.  

/ Tom Edelson

Reply via email to