Subject: | Constructor does not die if process cannot be accessed |
The following script, executed as a non-privileged user, gives a strange
error message:
#!/usr/bin/perl
use strict;
use Linux::Smaps;
my $ls = eval { Linux::Smaps->new(1) }
or die "Can't construct L::S object for pid=1: $@";
$ls->size;
__END__
The error message is (at least on Debian/squeeze, CentOS5, CentOS6):
Can't locate object method "size" via package "Linux::Smaps" at ...
Problem is that the new() call does not fail, but constructs an
incomplete object which causes the strange "can't locate object method"
errors afterwards.
Digging further into it, an open(..., "/proc/smaps/$unprivileged_pid")
does not fail on Linux, but a subsequent read fails. But the failing
read is not detected in Linux::Smaps::update().
Regards,
Slaven