my $pid = -999; while ($pid < 0 ) { # childLocalF is something like C:\temp\81.bat my $runMeLine = $childLocalF . ' ' . $runMeArgC; $runMeLine = $runMeLine . ' ' . id(); $runMeLine = $runMeLine . ' ' . '>C:\Temp\81.out 2>C:\Temp\81.err'; print "runMeLine = $runMeLine\n"; $pid = system( 1, $runMeLine ); print "XXX child PID = $pid\n"; if( $pid < 0 ) { #something went wrong with the system command. print "ERROR: System call failed\n"; print "ERROR: return value from system was $pid\n"; print "ERROR: runMeLine = $runMeLine\n"; $countSystemCallFailed++; if( $countSystemCallFailed > $cfg->{'maxSystemCallFailed'} ) { die "System call failed $countSystemCallFailed times\n"; } print "Sleeping 5 and will try again\n"; sleep( 5 ); } }