package Bug::Destroy::System;
sub new {
my $pkg = shift;
bless {}, $pkg;
}
sub DESTROY {
# we need to call some system routine
system("echo hello");
}
package main;
my $t = Bug::Destroy::System->new();
die "Oh, no, bad thing happened!";
__END__
####
rtg$ perl5.8.8 system-destroy-bug.pl; echo $?
Oh, no, bad thing happened! at system-destroy-bug.pl line 15.
hello
0
####
...
waitpid(24613, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 24613
rt_sigaction(SIGINT, {SIG_DFL}, NULL, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, 8) = 0
read(3, "", 4) = 0
close(3) = 0
exit_group(0) = ?
####
...
wait4(12266, [{WIFSIGNALED(s) && WTERMSIG(s) == 121} | 0x65747300], 0, NULL) = 12266
syscall_416(0x2, 0xbfbfe4f0, 0) = 0
syscall_416(0x3, 0xbfbfe4d0, 0) = 0
read(3, "", 4) = 0
close(3) = 0
exit(0) = ?