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

@@ -108,6 +108,12 @@ if ($opt_D) { # Output dependencies only
open my $out, '>', $opt_o or
die "Can't create $opt_o: $!\n";
$SIG{__DIE__} = sub {
die @_ if $^S; # Ignore eval deaths
close $out;
unlink $opt_o;
};
my $podHtml;
my $idify;
my $contentType =

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! */

View File

@@ -68,6 +68,12 @@ open my $inp, '<', $infile or
open my $out, '>', $opt_o or
die "podRemove.pl: Can't create $opt_o: $!\n";
$SIG{__DIE__} = sub {
die @_ if $^S; # Ignore eval deaths
close $out;
unlink $opt_o;
};
my $inPod = 0;
while (<$inp>) {
if (m/\A=[a-zA-Z]/) {

View File

@@ -93,6 +93,12 @@ my $root = '../' x scalar @inpath;
open my $out, '>', $opt_o or
die "Can't create $opt_o: $!\n";
$SIG{__DIE__} = sub {
die @_ if $^S; # Ignore eval deaths
close $out;
unlink $opt_o;
};
my $podHtml = EPICS::PodHtml->new();
$podHtml->html_css($root . 'style.css');