L
lala4life
Hi gurus.
I have some code using fork, work nice in linux. but it really
portable to win32?
hare is a snippet of the code.
in linux i use ps -xuaf and view the parent and his child process,
but in win32 i'n not sure about fork.
FORK:{
if ( $pid = fork && $max_openprocs++ < 11 ){
#parent process
push @PROC_LIST,$pid;
} elsif (defined($pid) && $max_openprocs < 10 ) {
# child process
if (!&trigger_link( $opt_url)){
# write a log message
open OUT, ">>$cronv_varglb::LOG_FILE" or die 'i cont ;
print OUT "# ".scalar localtime()." Can't access to
$opt_url by method GET \r\n";
close OUT;
};
exit;
} elsif ($! =~ /no more process/ || $max_openprocs > 10 ) {
#try to restore.
sleep 5;
#wait for 5 process ... and delete them from
@PROC_LIST
foreach my $i (0 ..$#PROC_LIST){
waitpid $PROC_LIST[$i],0;
delete $PROC_LIST[$i];
last if ($i == 5);
}
$max_openprocs = 5;
redo FORK;
} else {
# fatal Error, write log message
open OUT, ">>$cronv_varglb::LOG_FILE" or die 'Can't opent
Log file';
print OUT "# ".localtime()."Fatal Error can't do a fork
[$!] \r\n";
close OUT;
die "Can't use fork[$!]\n";
}; # if
};# FORK
I have some code using fork, work nice in linux. but it really
portable to win32?
hare is a snippet of the code.
in linux i use ps -xuaf and view the parent and his child process,
but in win32 i'n not sure about fork.
FORK:{
if ( $pid = fork && $max_openprocs++ < 11 ){
#parent process
push @PROC_LIST,$pid;
} elsif (defined($pid) && $max_openprocs < 10 ) {
# child process
if (!&trigger_link( $opt_url)){
# write a log message
open OUT, ">>$cronv_varglb::LOG_FILE" or die 'i cont ;
print OUT "# ".scalar localtime()." Can't access to
$opt_url by method GET \r\n";
close OUT;
};
exit;
} elsif ($! =~ /no more process/ || $max_openprocs > 10 ) {
#try to restore.
sleep 5;
#wait for 5 process ... and delete them from
@PROC_LIST
foreach my $i (0 ..$#PROC_LIST){
waitpid $PROC_LIST[$i],0;
delete $PROC_LIST[$i];
last if ($i == 5);
}
$max_openprocs = 5;
redo FORK;
} else {
# fatal Error, write log message
open OUT, ">>$cronv_varglb::LOG_FILE" or die 'Can't opent
Log file';
print OUT "# ".localtime()."Fatal Error can't do a fork
[$!] \r\n";
close OUT;
die "Can't use fork[$!]\n";
}; # if
};# FORK