#!/usr/bin/perl -w

@cmd = @ARGV;

$start = time();
$count = 0;
while(1) {
    print "pass $count, running command '", join(' ',@cmd),"'\n";
    $rc = system(@cmd);
    my $signum = $rc & 0xff;
    if ($signum) {
        print "Process died from signal $signum\n";
        last;
    }
    my $exitcode = $rc >> 8;
    if ($exitcode) {
        print "Process exited with exit code $exitcode\n";
        last;
    }
    my $elapsed = time() - $start;
    print "command completed successfully, ",
      "pass $count, elapsed time $elapsed seconds\n";
    $count++;
}

$elapsed = time() - $start;
print "loop terminated on pass $count after $elapsed seconds\n";
exit 1;
