I'd love to find out that this is pilot error (sorceror's apprentice error?), but I 
fear not.  It looks for all the world like, in certain circumstances, even if you 
attempt explicitly to re-establish a signal handler that's been used, it won't work a 
second time.  

$ perl -v

This is perl, v5.6.1 built for VMS_AXP

Script:

-- snip --

use strict;

use constant NL => "\n";

my $pid = $ENV {'HOLD_PID'};

print "Process ID is '$pid'.\n\n";


open (my $writeme, "| SPAWN /NOLOG") or die "\nCouldn't fork: $!\n\n";  

print "Open succeeded.\n\n";


print $writeme 'SET VERIFY', NL;

print $writeme 'SET NOON', NL;


print $writeme 'WRITE SYS$OUTPUT "Command 1."', NL;

synchronize ();

print 'FooBar!', NL;

print $writeme 'WRITE SYS$OUTPUT "Command 2."', NL;

synchronize ();

print $writeme 'WRITE SYS$OUTPUT "Command 3."', NL;


print $writeme 'LOGOUT', NL;


close ($writeme) or die "Close failed: $!\n\n";

print "\nClose done.\n\n";


sub synchronize {

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

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

} # end sub synchronize

-- snip --

Results:

Process ID is '2B217025'.

Open succeeded.

SET NOON
WRITE SYS$OUTPUT "Command 1."
Command 1.
PERL -e "print kill (ALRM, 0x2B217025)"
1
 FooBar!
WRITE SYS$OUTPUT "Command 2."
Command 2.
PERL -e "print kill (ALRM, 0x2B217025)"
1

and then it hangs.  You have to control-C out of the Perl program, and then manually 
STOP the two sub-processes which it has created (one directly by Perl via the piped 
open, and a second by the explicit SPAWN command in the first).  

Any ideas?

Thanks.  / Tom Edelson

Reply via email to