$SIG{CHLD} = IGNORE; #### $SIG{CHLD} = \&reap_the_children; sub reap_the_children { my $child; while (($child = waitpid(-1, &WNOHANG)) > 0) { my $file = $seen{$child}; print "Deleting $file from seen hash\n"; print "Deleting $child from seen hash\n"; delete $seen{$file}; delete $seen{$child}; } $SIG{CHLD} = \&reap_the_children; }