use Moo;
use System::Introspector::Util qw(
- handle_from_command
+ lines_from_command
transform_exceptions
);
sub gather {
my ($self) = @_;
return transform_exceptions {
- my $pipe = $self->_open_lsof_pipe;
+ my @lines = lines_from_command [$self->_lsof_command_call];
my @handles;
- while (defined( my $line = <$pipe> )) {
+ for my $line (@lines) {
chomp $line;
my @fields = split m{\0}, $line;
push @handles, { map {
};
}
-sub _open_lsof_pipe {
+sub _lsof_command_call {
my ($self) = @_;
- my $lsof = $self->lsof_command;
- return handle_from_command "$lsof -F0";
+ return $self->lsof_command, '-F0';
}
1;
$in = ''
unless defined $in;
my ($out, $err) = ('', '');
- my $ok = run($command, \$in, \$out, \$err);
+ my $ok = eval { run($command, \$in, \$out, \$err) or die $err};
+ $err = $@ unless $ok;
return $out, $err, $ok
if wantarray;
$command = join ' ', @$command