File: runfor

package info (click to toggle)
plum 2.33.1-9
  • links: PTS
  • area: main
  • in suites: sarge, woody
  • size: 908 kB
  • ctags: 128
  • sloc: perl: 4,442; makefile: 51
file content (31 lines) | stat: -rwxr-xr-x 500 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/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";
}