in reply to Forking and running all child processes at the same time
my @files = qw(file1 file2 file3); # your log-files for (1..scalar(@files)){ next unless(-e $files[$_-1]); my $pid=fork(); if($pid==-1){ warn($!); last; } if($pid){ $pids{$pid}=1; } else{ # do what you want with $files[$_-1] exit(0); } } while(keys %pids){ my $pid=waitpid( -1, WNOHANG ); die "$!" if $pid == -1; delete $pids{$pid}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Forking and running all child processes at the same time
by tlm (Prior) on Jun 06, 2005 at 12:45 UTC |