You might want to look at Killing children's of children and Proc::Killfam. On linux anyways, sometimes when you fork, you get the pid of the shell which is spawned to run your child, so there is an hidden pid in there. Killfam will find them all, and kill them.