in reply to How to test exit?

My approach would be to fork and check the exit. You'd probably want to add a timeout feature to kill tenacious subs that fail to exit. Really stripped-down example:
use strict; use warnings; sub test_exit { my ($subr, $exit_val) = @_; my $subp = fork; if ($subp) { my $done = waitpid($subp, 0); print "Process $done Exited with ".($?>>8).", expected $exit_val\n +"; } else { $subr->(); warn "Did not exit\n"; exit (~$exit_val); } } test_exit(sub{print "Process has run\n"; exit(42)}, 42);

Caution: Contents may have been coded under pressure.