in reply to dbi and fork
$ppid = getppid;
and then terminate when the parent does:
while (getppid == $ppid) { # process until parent dies } [download]
If the code and the comments disagree, then both are probably wrong. -- Norm Schryer