Subject: | clarify get_rlimits() docs |
Date: | Thu, 21 Jan 2010 08:37:13 +1100 |
To: | bug-BSD-Resource [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
I found the example code with get_rlimits() a bit unclear
$r = get_rlimits();
print "ok.\n" if ($r->{'RLIM_STACK'} == RLIM_STACK);
It uses the RLIM_STACK constant, yet checking whether such a constant
exists is the reason for calling get_rlimits()!
I see it's trying to say the value in the hash is the value of the
constant, but it might be better to put that in words and something more
likely as example code, eg.
my $limits = BSD::Resource::get_rlimits();
foreach my $name (keys %$limits) {
my ($soft, $hard) = BSD::Resource::getrlimit ($limits->{$name});
print "$name soft $soft hard $hard\n";
}
I wondered too whether BSD::Resource->can('RLIMIT_STACK') works as well.
There could be a note on that. Of course can() can't list the available
limits, but can ask if a particular constant exists.