#!/bin/perl -w
# $Id: runfor,v 2.3 1998/11/11 03:25:35 hasegawa Exp $
# 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";
}
