#Start fork
foreach my $xml_obj (@{$xml_ojects_ref}){
my $pid = fork();
if ($pid) {
# parent
push(@childs, $pid);
$framework_child_procs{$pid} = 1;
}elsif($pid == 0) {
# child
my $results = new testProcess($xml_obj,$fatherSN); #Test process is a new run
exit 0;
}else {
print ,"couldnt fork: $!";
exit 1;
}
}
#Wait for to end
foreach my $child (@childs) {
my $tmp = waitpid($child, 0);
print "done with pid $tmp";
}
####
$SIG{INT}=\&ctrl_c_handler;
sub ctrl_c_handler
{
$SIG{'INT'}='IGNORE';
my @procs = keys (%{fatherProcess::framework_child_procs});
kill SIGUSR1 => @procs;
foreach my $child (@procs) {
my $tmp = waitpid($child, 0);
}
}
##
##
my $t = threads->new (sub{
local $SIG{'USR1'}=sub {threads->exit();};
\&$functions_name(@parameters);
});
my $result = $t->join();