#!/bin/perl -w
# $Id: runfor 81 2003-03-22 16:39:56Z tach $
# copyright (c)1997 Yoshinori Hasegawa <hasegawa@madoka.org>

$WAITTIME = 60;

&main(@ARGV);

sub main {
  local(@args) = @_;
  local($pid);

  if (@args < 1) {
    &usage();
    exit(1);
  }
  for (;;) {
    $pid = fork();
    if (!defined($pid)) {
      sleep($WAITTIME);
    } elsif ($pid == 0) {
      exec(@args);
    } else {
      wait;
    }
  }
}

sub usage {
  print 'usage: perl runfor <command> [<args>]', "\n";
}
