| 1 | # Copyrights 2011-2013 by [Mark Overmeer]. | ||||||||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.01. | ||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 4 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | package POSIX::1003::Limit; | ||||||||||||||||||||
| 9 | 4 | ▶ | use vars '$VERSION'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 1 | $VERSION = '0.98'; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 4 | ▶ | use base 'POSIX::1003::Module'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 1 | ▶ | use Carp 'croak'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 1 | my (@ulimit, @rlimit, @constants, @functions); | |||||||||||||||||||
| 17 | 1 | our %EXPORT_TAGS = | |||||||||||||||||||
| 18 | ( ulimit => \@ulimit | ||||||||||||||||||||
| 19 | , rlimit => \@rlimit | ||||||||||||||||||||
| 20 | , constants => \@constants | ||||||||||||||||||||
| 21 | , functions => \@functions | ||||||||||||||||||||
| 22 | , tables => [ qw/%ulimit %rlimit/ ] | ||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 1 | my ($ulimit, $rlimit); | |||||||||||||||||||
| 26 | 1 | our (%ulimit, %rlimit); | |||||||||||||||||||
| 27 | 1 | my ($rlim_saved_max, $rlim_saved_cur, $rlim_infinity); | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | BEGIN { | ||||||||||||||||||||
| 30 | 1 | ▶ | my @ufuncs = qw/ulimit ulimit_names/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | 1 | my @rfuncs = qw/getrlimit setrlimit rlimit_names/; | |||||||||||||||||||
| 32 | 1 | my @rconst = qw/RLIM_SAVED_MAX RLIM_SAVED_CUR RLIM_INFINITY/; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 1 | $ulimit = ulimit_table; | |||||||||||||||||||
| 35 | 1 | @ulimit = (keys %$ulimit, @ufuncs, '%ulimit'); | |||||||||||||||||||
| 36 | 1 | tie %ulimit, 'POSIX::1003::ReadOnlyTable', $ulimit; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 1 | $rlimit = rlimit_table; | |||||||||||||||||||
| 39 | 1 | @rlimit = (keys %$rlimit, @rfuncs, @rconst, '%rlimit'); | |||||||||||||||||||
| 40 | 1 | tie %rlimit, 'POSIX::1003::ReadOnlyTable', $rlimit; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 1 | push @constants, keys %$ulimit, keys %$rlimit; | |||||||||||||||||||
| 43 | 1 | push @functions, @ufuncs, @rfuncs; | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 1 | $rlim_saved_max = delete $rlimit->{RLIM_SAVED_MAX}; | |||||||||||||||||||
| 46 | 1 | $rlim_saved_cur = delete $rlimit->{RLIM_SAVED_CUR}; | |||||||||||||||||||
| 47 | 1 | $rlim_infinity = delete $rlimit->{RLIM_INFINITY}; | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | ▶ | sub RLIM_SAVED_MAX { $rlim_saved_max } | ||||||||||||||||||
|
Subroutine
RLIM_SAVED_MAX: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 51 | 0 | ▶ | sub RLIM_SAVED_CUR { $rlim_saved_cur } | ||||||||||||||||||
|
Subroutine
RLIM_SAVED_CUR: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 52 | 0 | ▶ | sub RLIM_INFINITY { $rlim_infinity } | ||||||||||||||||||
|
Subroutine
RLIM_INFINITY: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | sub getrlimit($); | ||||||||||||||||||||
| 55 | sub setrlimit($$;$); | ||||||||||||||||||||
| 56 | sub ulimit($;$); | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | sub exampleValue($) | ||||||||||||||||||||
| 60 | 0 | ▶ | { my ($class, $name) = @_; | ||||||||||||||||||
|
Subroutine
exampleValue: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||
| 61 | 0 | ▶ | if($name =~ m/^RLIMIT_/) | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 62 | 0 | { my ($soft, $hard, $success) = getrlimit $name; | |||||||||||||||||||
| 63 | 0 | ▶ | $soft //= 'undef'; | ||||||||||||||||||
|
Condition0%0/2
$soft //= "undef"
MC/DC0%0/1
$soft //= "undef"
$soft
Truth table0%0/2
A
A= $soft
| |||||||||||||||||||||
| 64 | 0 | ▶ | $hard //= 'undef'; | ||||||||||||||||||
|
Condition0%0/2
$hard //= "undef"
MC/DC0%0/1
$hard //= "undef"
$hard
Truth table0%0/2
A
A= $hard
| |||||||||||||||||||||
| 65 | 0 | return "$soft, $hard"; | |||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | elsif($name =~ m/^UL_GET|^GET_/) | ||||||||||||||||||||
| 68 | 0 | { my $val = ulimit $name; | |||||||||||||||||||
| 69 | 0 | ▶ | return defined $val ? $val : 'undef'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | elsif($name =~ m/^UL_SET|^SET_/) | ||||||||||||||||||||
| 72 | 0 | { return '(setter)'; | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | else | ||||||||||||||||||||
| 75 | 0 | { $class->SUPER::exampleValue($name); | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | sub ulimit($;$) | ||||||||||||||||||||
| 81 | 0 | ▶ | { my $key = shift // return; | ||||||||||||||||||
|
Subroutine
ulimit: not called CC=7 SCAR=40.3
Pod
documented
Condition0%0/2
shift() // (return)
MC/DC0%0/1
shift() // (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||
| 82 | 0 | ▶ | if(@_) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 83 | 0 | ▶ | { $key =~ /^UL_SET|^SET_/ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 84 | or croak "pass the constant name as string ($key)"; | ||||||||||||||||||||
| 85 | 0 | ▶ | my $id = $ulimit->{$key} // return; | ||||||||||||||||||
|
Condition0%0/2
$ulimit->{$key} // (return)
MC/DC0%0/1
$ulimit->{$key} // (return)
$ulimit->{$key}
Truth table0%0/2
A
A= $ulimit->{$key}
| |||||||||||||||||||||
| 86 | 0 | return _ulimit($id, shift); | |||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | else | ||||||||||||||||||||
| 89 | 0 | ▶ | { $key =~ /^UL_GET|^GET_/ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 90 | or croak "pass the constant name as string ($key)"; | ||||||||||||||||||||
| 91 | 0 | ▶ | my $id = $ulimit->{$key} // return; | ||||||||||||||||||
|
Condition0%0/2
$ulimit->{$key} // (return)
MC/DC0%0/1
$ulimit->{$key} // (return)
$ulimit->{$key}
Truth table0%0/2
A
A= $ulimit->{$key}
| |||||||||||||||||||||
| 92 | 0 | _ulimit($id, 0); | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | sub _create_constant($) | ||||||||||||||||||||
| 97 | 0 | ▶ | { my ($class, $name) = @_; | ||||||||||||||||||
|
Subroutine
_create_constant: not called CC=5 SCAR=34.0
| |||||||||||||||||||||
| 98 | 0 | ▶ | if($name =~ m/^RLIMIT_/) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 99 | 0 | ▶ | { my $id = $rlimit->{$name} // return sub() {undef}; | ||||||||||||||||||
|
Condition0%0/2
$rlimit->{$name} // (return sub () { undef }
)
MC/DC0%0/1
$rlimit->{$name} // (return sub () { undef }
)
$rlimit->{$name}
Truth table0%0/2
A
A= $rlimit->{$name}
| |||||||||||||||||||||
| 100 | 0 | ▶ | return sub(;$$) { @_ ? _setrlimit($id, $_[0], $_[1]) : (_getrlimit($id))[0] }; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||
| 101 | } | ||||||||||||||||||||
| 102 | else | ||||||||||||||||||||
| 103 | 0 | ▶ | { my $id = $ulimit->{$name} // return sub() {undef}; | ||||||||||||||||||
|
Condition0%0/2
$ulimit->{$name} // (return sub () { undef }
)
MC/DC0%0/1
$ulimit->{$name} // (return sub () { undef }
)
$ulimit->{$name}
Truth table0%0/2
A
A= $ulimit->{$name}
| |||||||||||||||||||||
| 104 | return $name =~ m/^UL_GET|^GET_/ | ||||||||||||||||||||
| 105 | 0 | ▶ | ? sub() {_ulimit($id, 0)} : sub($) {_ulimit($id, shift)}; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||
| 106 | } | ||||||||||||||||||||
| 107 | } | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | sub getrlimit($) | ||||||||||||||||||||
| 111 | 0 | ▶ | { my $key = shift // return; | ||||||||||||||||||
|
Subroutine
getrlimit: not called CC=4 SCAR=30.0
Pod
documented
Condition0%0/2
shift() // (return)
MC/DC0%0/1
shift() // (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||
| 112 | 0 | ▶ | $key =~ /^RLIMIT_/ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 113 | or croak "pass the constant name as string ($key)"; | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | 0 | my $id = $rlimit->{$key}; | |||||||||||||||||||
| 116 | 0 | ▶ | defined $id ? _getrlimit($id) : (); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 117 | } | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | sub setrlimit($$;$) | ||||||||||||||||||||
| 121 | 0 | ▶ | { my ($key, $cur, $max) = @_; | ||||||||||||||||||
|
Subroutine
setrlimit: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||
| 122 | 0 | ▶ | $key =~ /^RLIMIT_/ | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 123 | or croak "pass the constant name as string ($key)"; | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | 0 | my $id = $rlimit->{$key}; | |||||||||||||||||||
| 126 | 0 | ▶ | $max //= RLIM_INFINITY; | ||||||||||||||||||
|
Condition0%0/3
$max //= RLIM_INFINITY()
MC/DC0%0/2
$max //= RLIM_INFINITY()
$max
RLIM_INFINITY()
Truth table0%0/3
A //= B
A= $maxB= RLIM_INFINITY()
| |||||||||||||||||||||
| 127 | 0 | ▶ | defined $id ? _setrlimit($id, $cur, $max) : (); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 128 | } | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | 0 | ▶ | sub ulimit_names() { keys %$ulimit } | ||||||||||||||||||
|
Subroutine
ulimit_names: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | 0 | ▶ | sub rlimit_names() { keys %$rlimit } | ||||||||||||||||||
|
Subroutine
rlimit_names: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 135 | |||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | |||||||||||||||||||||
| 138 | 1 | 1; | |||||||||||||||||||