in reply to Fork/Child Question

The fork function is behind anything that can do that aside from threads. That is because fork creates a new process with the same environment the original process has. It therefore returns twice, returning 0 in the child process, and the child's pid or undef in the parent. The undef return indicates failure of fork.

The basic receipe is to branch the execution stream after fork, with the parent going on and the child directed to do it's job and exit. The exec function is useful if the child is to do a system call.

To avoid zombie processes, either set up an appropriate SIGCHLD handler or call wait/waitpid after the kids are launched.

There is a limit to the number of child processes you can have, or should want, so big jobs may require the kind of throttling Parallel::ForkManager gives you.

The receipe:

$SIG{CHLD} = 'IGNORE'; # check if it works on your system for (1..100) { my $pid = fork; next if $pid; # in parent, go on warn($!), next if not defined $pid; # parent, fork errored out exec @cmd; # in child, # go do @cmd and don't come back }

After Compline,
Zaxo