Fork in windows

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

fork/exec question 6
fork and blocking... 3
fork() & pipe() 3
Linux: using "clone3" and "waitid" 0
Fork (and exec) in a threaded script. 4
issue with multiprocess - fork 2
problem with fork 8
Fork Problem 2

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top