home *** CD-ROM | disk | FTP | other *** search
/ ftp.madoka.org / 2014.12.ftp.madoka.org.tar / ftp.madoka.org / pub / plum / plum2_33_1.lzh / support / runfor < prev    next >
Text File  |  1999-03-24  |  496b  |  32 lines

  1. #!/bin/perl -w
  2. # $Id: runfor,v 2.3 1998/11/11 03:25:35 hasegawa Exp $
  3. # copyright (c)1997 Yoshinori Hasegawa <hasegawa@madoka.org>
  4.  
  5. $WAITTIME = 60;
  6.  
  7. &main(@ARGV);
  8.  
  9. sub main {
  10.   local(@args) = @_;
  11.   local($pid);
  12.  
  13.   if (@args < 1) {
  14.     &usage();
  15.     exit(1);
  16.   }
  17.   for (;;) {
  18.     $pid = fork();
  19.     if (!defined($pid)) {
  20.       sleep($WAITTIME);
  21.     } elsif ($pid == 0) {
  22.       exec(@args);
  23.     } else {
  24.       wait;
  25.     }
  26.   }
  27. }
  28.  
  29. sub usage {
  30.   print 'usage: perl runfor <command> [<args>]', "\n";
  31. }
  32.