English 中文(简体)
页: 1
原标题:
  • 时间:2009-05-26 16:14:51
  •  标签:

∗∗∗∗∗

for $p (@a){
    system("/path/to/file.sh $p&");
}

页: 1

最佳回答

Us/ex/wa

my @a = (1, 2, 3);
for my $p (@a) {
   my $pid = fork();
   if ($pid == -1) {
       die;
   } elsif ($pid == 0) {
      exec  /bin/sleep , $p or die;
   }
}
while (wait() != -1) {}
print "Done
";
问题回答

< >>,>>,>,<>>>,>,>,>,>,>,>,>,>,>,>,>,>,>,>,<>,>,>,>,<>,>,>,>

纽约总部

#!/bin/bash

$*

touch /tmp/$2.$PPID

——————

for my $p (@a){
    system("/path/to/wrapper.sh /path/to/file.sh $p &");
}
while (@a) {
    delete $a[0] if -f "/tmp/$a[0].$$";
}

∗∗∗∗

my @pids;
for my $p (@a) {
    die "could not fork" unless defined(my $pid = fork);
    unless ($pid) { #child execs
        exec "/path/to/file.sh", $p;
        die "exec of file.sh failed";
    }
    push @pids, $pid; #parent stores children s pids
}

#wait for all children to finish
for my $pid (@pids) {
    waitpid $pid, 0;
}

<0> > > > : >;<>;>;<>;>;>;<>;>;>;>;>;>;>;>;>;>; 页: 1

<> > > > > > > > > > > > >





相关问题
热门标签