in reply to fork()ing a large process
Then you don't have to worry about your code blocking while waiting for children to return. However this doesn't mean you should do something like.use POSIX qw(:sys_wait_h); sub REAPER { while ((my $pid = waitpid(-1,WNOHANG)) > 0) { # do something with $pid; } $SIG{CHLD} = \&REAPER; } $SIG{CHLD} = \&REAPER;
Speaking as a system administrator this won't earn you alot of good sysadmin karma. It is ok to fork many children just remember to limit the number of children on the system at any one time. Please read perlipc and perlfork they helped me out big time.sub fork_bomb { while (1){ fork_a_kid(); } }
|
---|