TeKk9 has asked for the wisdom of the Perl Monks concerning the following question:
while(1) { $processes = 0; foreach $compressedFile ( @pdfFiles ) { $pdfFile = $compressedFile; $pdfFile =~ s/\.Z//; # - For each pdf file fork a new process upto MAX_PROCESSES. if( $my_pid = fork()) { $processes++; if( $processes >= $MAX_PROCESSES ) { $wait = wait(); print "WAIT => $wait\n" if( $debug ); print "PID => $my_pid\n" if( $debug ); if( $wait ) { $processes-- ; } } elsif ( !defined $my_pid ) { die "Error: Cannot fork process: $!"; } } elsif ( $my_pid == 0 ) { &load_file($pdfFile); exit 0; } } if( $daemon_mode ) { $sleep = $sleepTime; print "LOAD_PDF => Sleeping $sleep seconds\n" if( $debug ); sleep $sleep; } else { print "LOAD_PDF => Finished!\n" if ($debug); exit 0; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Daemonized with max processes
by Aristotle (Chancellor) on Aug 14, 2003 at 21:24 UTC | |
|
•Re: Daemonized with max processes
by merlyn (Sage) on Aug 14, 2003 at 22:19 UTC | |
|
Re: Daemonized with max processes
by dtr (Scribe) on Aug 14, 2003 at 22:04 UTC | |
|
Re: Daemonized with max processes
by Marcello (Hermit) on Aug 15, 2003 at 09:38 UTC | |
|
Re: Daemonized with max processes
by jmanning2k (Pilgrim) on Aug 15, 2003 at 14:25 UTC |