$pm->run_on_finish(
sub { my ($pid, $exit_code, $ident) = @_;
print "** $ident just got out of the pool ".
"with PID $pid and exit code: $exit_code\n";
}
);
####
$thr4 = threads->new(\&processor);
$thr4->detach;
while (1){
sleep(1);
#$pm->wait_all_children;
}
####
sub processor{
my @row;
while (1){
if ($sys_ok){
@row = &row_sql("select * from pool_process where srv='$server_id';");
if (!(@row)){
#print "Nothing to do...\n";
}else{
&del_sql("delete from pool_process where id='@row[0]';");
print "Processing (@row[1],@row[2],@row[3],@row[4])\n";
#my $thr = threads->create(\&process_start,@row[1],@row[2],@row[3],@row[4],@row[5]);
$child_processor++;
my $pid = $pm->start($child_processor) and next;
&process_start(@row[1],@row[2],@row[3],@row[4],@row[5]);
print "Child about to get out ($$)\n";
system("kill $$");
$pm->finish($child_processor); # Terminates the child process
print "Finished Child!";
}
sleep(2);
}else{
sleep(30);
}
#$pm->wait_all_children;
}
}