NAME
POSIX::1003::Limit - POSIX access to ulimit and rlimit
INHERITANCE
POSIX::1003::Limit
is a POSIX::1003
SYNOPSIS
# ULIMIT support
use POSIX::1003::Limit; # load all names
use POSIX::1003::Limit qw(ulimit);
# keys are strings!
$size = ulimit('UL_GETFSIZE');
use POSIX::1003::Limit qw(ulimit UL_GETFSIZE);
$size = UL_GETFSIZE; # constants are subs
use POSIX::1003::Limit '%ulimit';
my $key = $ulimit{UL_GETFSIZE};
$ulimit{_SC_NEW_KEY} = $key_code;
$size = ulimit($key);
print "$_\n" for keys %ulimit;
# RLIMIT support
use POSIX::1003::Limit ':rlimit';
my ($cur, $max, $success) = getrlimit('RLIMIT_CORE');
my ($cur, $max) = getrlimit('RLIMIT_CORE');
my $cur = RLIMIT_CORE;
my $success = setrlimit('RLIMIT_CORE', 1e6, 1e8);
setrlimit('RLIMIT_CORE', 1e6) or die;
setrlimit('RLIMIT_CORE', RLIM_SAVED_MAX, RLIM_INFINITY);
RLIMIT_CORE(1e6, 1e8);
DESCRIPTION
This module provides access to the "ulimit" (user limit) and "rlimit" (resource limit) handling. On most systems, ulimit()
is succeeded by rlimit()
hence provides a very limited set of features.
FUNCTIONS
Standard POSIX
- getrlimit(RESOURCE)
-
my ($cur, $max, $success) = getrlimit('RLIMIT_CORE'); my ($cur, $max) = getrlimit('RLIMIT_CORE');
- setrlimit(RESOURCE, CUR, [MAX])
-
my $success = setrlimit('RLIMIT_CORE', 1e6, 1e8);
- ulimit(NAME)
-
Returns the ulimit value related to the NAMEd constant. The NAME must be a string.
undef
will be returned when the NAME is not known by the system.my $filesize = ulimit('UL_GETFSIZE') || SSIZE_MAX;
Additional
- rlimit_names()
-
Returns a list with all known resource names, unsorted.
- ulimit_names()
-
Returns a list with all known names, unsorted.
CONSTANTS
- %ulimit
-
This exported variable is a tied HASH which maps
UL_*
names on unique numbers, to be used with ulimit(). - %rlimit
-
This exported variable is a tied HASH which maps
RLIMIT_*
names on unique numbers, to be used with getrlimit() and setrlimit().
SEE ALSO
This module is part of POSIX-1003 distribution version 0.04, built on December 22, 2011. Website: http://perl.overmeer.net. The code is based on POSIX, which is released with Perl itself.
COPYRIGHTS
Copyrights of the perl code and the related documentation by 2011 by Mark Overmeer. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html