#!/usr/bin/perl use strict; use lib '/homegrown/lib'; use MY_Logging; use MY_File qw(slurp); use POSIX qw(:signal_h :errno_h :sys_wait_h); select STDERR; $|=1; our ($me) = $0 =~ m/\/?([^\/]+)$/; my %children; my $child; $SIG{CHLD} = \&REAPER; sub REAPER { my $reaped_pid = waitpid(-1, &WNOHANG); if ($reaped_pid == -1) { } elsif (WIFEXITED($?)) { delete $children{$reaped_pid}; print STDERR slurp("$me.$reaped_pid.log"); } else { logMsg("False alarm on $reaped_pid"); } $SIG{CHLD} = \&REAPER; } if ($child = fork()) { $children{$child} = 'TEST'; logMsg("spawned pid $child"); } else { close(STDERR); my $LOG = "$me.$$.log"; open (STDERR, ">>$LOG") or dieScreaming("$LOG open failure: $!"); select STDERR; $|=1; foreach my $host ('eidspstd01', 'eiqspstd01') { my $cmd = "..."; logMsg("executing $cmd"); my $CMD_LOG = "$me.$$.load.log"; system("$cmd >$CMD_$LOG 2>&1"); logLog($CMD_LOG); # pull in cmd log contents to STDERR } logMsg("completed TEST"); close(STDERR); exit(0); } # wait for any children that may be running still while (%children) { logMsg("WATING FOR: ", join(',', values %children)); sleep(5); } logMsg("$me complete");