I want to use threads with mod_perl,
as a sample I use following script:
use strict;
use warnings;
use threads;
sub doOperation{
my $vr = $_[0];
my $i = 0;
while($i < 10000000){
$i++
}
print "Thread done! var1 = $vr\n";
threads->exit();
}
my @thr;
$thr[0] = threads->create(\&doOperation,5);
$thr[1] = threads->create(\&doOperation,6);
foreach(@thr){ $_->join(); }
I works smooth using CLI:
# perl multithr.pl
Thread done! var1 = 6
Thread done! var1 = 5
However if run it through Apache mod_perl module it causes Segmentation fault error.
My Environment:
CentOS-6.5 x86_64
httpd-2.2.15
mod_perl-2.0.4