in reply to How to test exit?
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);
|
---|