--- a/bin/amdumpext Mon Dec 16 11:13:32 2013 +0100
+++ b/bin/amdumpext Mon Dec 16 14:31:18 2013 +0100
@@ -17,6 +17,7 @@
use 5.010;
use strict;
use warnings;
+use Carp;
use Pod::Usage;
use Getopt::Long;
use File::Basename;
@@ -242,12 +243,20 @@
die "Can't exec `restore -tvf -`: $!";
};
+ # the restore may close it's input, we'll get
+ # a SIG{PIPE} because of this
+ local $SIG{PIPE} = sub {
+ close $restore;
+ $restore = undef;
+ $SIG{PIPE} = 'default';
+ };
+
local $/ = \(my $x = 64 * 1024);
while (<STDIN>) {
print $_;
- print $restore $_;
+ print $restore $_ if $restore;
}
- close($restore);
+ close($restore) if $restore;
exit 0;
};
@@ -289,7 +298,7 @@
exit 0;
};
exec @dump;
- die "Can't exec `@dump`: $!\n";
+ die "Can't exec `@dump': $!\n";
}
waitpid($pid, 0);
exit $?;
@@ -330,7 +339,8 @@
# restore to use a \0 separated output format
select +shift;
- local $/ = "\n"; # make sure to have it line separated!
+ die 'IFS is not as expected!' if $/ ne "\n";
+
my $buffer = undef;
my $type = undef;
@@ -343,7 +353,7 @@
if (1 .. defined && /\Adir\s+\d+\s+(.*)\Z/) {
$buffer = '';
$type = 'dir';
- die "Unexpected end of input\n" if not defined;
+ die "Unexpected end of input while reading from restore -tvf\n" if not defined;
next;
}