xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I have a script works well on Unix but is broken on Win32. I've found wait function might be the devil. Below is my test snippet:
use strict; use warnings; my $max_process = 10; my $processes = 0; for my $count (1..100){ wait if $processes >= $max_process; do{print $count."\n";exit} unless my $pid = fork; $processes ++; }
I hope it print 1 to 100 in turn, but the output is totally insane. Eventually it print 'out of memory' and crash. I guess the reason is wait can't treat negative pid number correctly.
So my question is whether my script could be reused on win32 by a little work or I have to totally rewrite it in thread?
Thanks!I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction
Back to
Seekers of Perl Wisdom