
Untitled
By: a guest on
May 2nd, 2012 | syntax:
None | size: 0.98 KB | hits: 16 | expires: Never
#!/usr/bin/perl
use strict;
use warnings;
use POSIX;
$| = 1;
my $running = 0;
my $permitted = 10;
sub processCompleted()
{
while (waitpid(-1, WNOHANG) > 0)
{
$running--;
}
}
# signal processing
$SIG{CHLD} = \&processCompleted;
my $file = 'domaintmp/domainsfull';
open FILE, '<', $file or die "Could not open $file\n";
while (my $line = readline FILE)
{
if ($running < $permitted)
{
my $pid = fork();
if ($pid)
{
# parent
$running++;
}
elsif ($pid == 0)
{
# child
my $tmpfile = "/tmp/domain-check.$$";
open TMPFILE, '>', $tmpfile;
print TMPFILE $line;
close TMPFILE;
my $command = "/home/simon/ssl-check.sh -i -f $tmpfile >> domaintmpout/$$.log 2>&1";
print "$command\n";
system ($command);
unlink $tmpfile;
exit 0;
}
}
else
{
sleep 1;
}
}
close FILE;
while (waitpid(-1, WNOHANG) > 0)
{
sleep 1;
}
exit 0;