in reply to controling the num of fork sessions

Well, for starters it will be easier if you do your work in the children, and keep track of them using the parent.

Here's a bit of untested code that should probably do the trick...

#!/usr/bin/perl use POSIX ":sys_wait_h"; $MAX = 20; #max num of children at a given time $SIG{CHLD} = \&REAPER; #deal with our children @list = (1,2,3); $count = 0; #number of children outstanding foreach $item ($list) { while($count >= $MAX) { #too many children, wait awhile sleep(1); } if(fork) { #Parent $count++; next; } else { #Child print("$item\n"); #do some child stuff here exit; } } sub REAPER { my $pid; while($pid = waitpid(-1,&WNOHANG)) { last if($pid == -1); $count--; #Decrement our outstanding children } \&REAPER; #Reinstall the signal hanler }


cephas