use IPC::Open3; my $status; sub status () { print "Status is: $status\n"; $SIG{USR1} = \&status; } $SIG{USR1} = \&status; print "$$\n"; my @paths; my $c = 10; push @paths,"sleep ".$c++ for 0 .. 3; $c = 0; foreach $path (@paths) { print "loop ",++$c,"\n"; my $pid = open3(*CMD_IN, *CMD_OUT, *CMD_ERR, $path); $status = $path; waitpid($pid, 0); print "after waitpid\n"; } #### 3297 loop 1 Status is: sleep 10 Status is: sleep 10 Status is: sleep 10 after waitpid loop 2 Status is: sleep 11 Status is: sleep 11 Status is: sleep 11 #### print "Status is: $status\n"; #### sub default { print "got SIG ".shift()."\n"} $SIG{$_} = \&default for keys %SIG; $SIG{USR1} = \&status; #### #!/usr/bin/perl # have to print to a terminal directly, # since default file handles are re-directed open O ,'>', '/dev/pts/1'; sub default { my $sig = shift; print O "child Status: got SIG$sig\n"; $SIG{$sig} = \&default; } $SIG{$_} = \&default for keys %SIG; sleep $_ for 1..shift; #### 3437 loop 1 child Status: got SIGINT got SIG INT got SIG CHLD after waitpid loop 2 ...