in reply to Runaway Forking Problem (was: simple perl2)

I have a few suggestions:
  1. You should take your fork/exec logic out of that infinite loop. If you are ending up with "heaps of processes" the loop is the main reason why.
  2. I think blindly exec-ing something from ‹STDIN› is a very bad idea. Maybe you're the only one who'll be using that program, but if I were you I'd want to examine $cmd before running it. This might be a place where taint mode would be useful.
  3. Don't leave a child process hanging about if the exec failed:   exec $cmd or die;