Linux-Fuser
view release on metacpan or search on metacpan
lib/Linux/Fuser.pm view on Meta::CPAN
use vars qw($AUTOLOAD);
sub new
{
my ( $class, $pid, $fd_data ) = @_;
my $fd = $fd_data->[0];
my $fd_no = $fd_data->[1];
my $user = getpwuid( ( lstat($fd) )[4] );
my @cmd = ('');
if ( open CMD, "/proc/$pid/cmdline" )
{
chomp( @cmd = <CMD> );
}
my $filedes = Linux::Fuser::FileDescriptor->new($pid, $fd_no);
open(F,">$$.tmp");
my @procs = $f->fuser("$$.tmp");
ok(@procs,"The file has users");
my ($proc ) = @procs;
isa_ok($proc,'Linux::Fuser::Procinfo');
my $pid = $proc->pid();
is($pid,$$,"Got the right PID");
my $user = $proc->user();
is($user,scalar getpwuid($>), "And I'm the right user");
my $filedes = $proc->filedes();
isa_ok($filedes, 'Linux::Fuser::FileDescriptor');
like($filedes->fd(),qr/\d+/, "fd() is a number");
close F;
};
ok(!$@, "Works for existing file");
my $f = Linux::Fuser->new();
eval
( run in 0.344 second using v1.01-cache-2.11-cpan-8d75d55dd25 )