in reply to forking and exec

You have to account for the return signals. Try this:
#avoid zombies $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 }

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Replies are listed 'Best First'.
Re^2: forking and exec
by Anonymous Monk on Oct 22, 2013 at 13:59 UTC
    why do you need to care about the return signals? I thought exec didn't care and only returned anything if the command was found?

      exec never returns, but any child that doesn't get reaped becomes a zombie_process. See perlipc, wait, waitpid. The easiest way to handle it is with $SIG{CHLD} = "IGNORE";, which tells perl to autoreap.


      #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

        Thanks. That explains the left over jobs that crash the system. Looks like I have some more book learnin' to do to fully grok this.