if ($@) { kill $your_favorite_sig, $pid; waitpid($pid, 0); } else { .... }