in reply to Killing wayward children
Why not use process group id? When you fork a child process, the child process inherits the process group id. We have getpgrp func to find out the process grp id of a process id, and just don't kill it, if it has a different process grp id. There also a func to set process group id.