use POSIX; use constant MAX_CHILDS => 6; my $CHILD_COUNT = 0; $SIG{CHLD} = \&Reaper; sub Reaper { my $childPid; while (($childPid = waitpid(-1, &WNOHANG)) > 0) { $CHILD_COUNT--; } $SIG{CHLD} = \&Reaper; } if ($CHILD_COUNT < MAX_CHILDS) { my $pid; if (!defined($pid = fork())) { # Fork failed } # Child process elsif ($pid == 0) { # Process file } # Parent process else { $CHILD_COUNT++; } }
In reply to Re: Daemonized with max processes
by Marcello
in thread Daemonized with max processes
by TeKk9
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |