Perl: Close and delete output files when dying

This commit is contained in:
Andrew Johnson
2020-05-26 21:52:55 -05:00
parent 808cf80579
commit 7ba12f600c
4 changed files with 24 additions and 0 deletions

View File

@@ -126,6 +126,12 @@ my $guard = "INC_${stem}API_H";
open my $o, '>', $outfile or
die "makeAPIheader.pl: Can't create $outfile: $!\n";
$SIG{__DIE__} = sub {
die @_ if $^S; # Ignore eval deaths
close $o;
unlink $outfile;
};
print $o <<"__EOF__";
/* This is a generated file, do not edit! */