# in the child: while (whatever...) { do_some_work(); if (getppid() == 1) { print "my parent is dead!"; clean_up(); exit; } }