line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyrights 2011-2015 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
|
|
|
4
|
|
32476
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
98
|
|
6
|
4
|
|
|
4
|
|
11
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
139
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package POSIX::1003::Limit; |
9
|
4
|
|
|
4
|
|
17
|
use vars '$VERSION'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
182
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.99_07'; |
11
|
|
|
|
|
|
|
|
12
|
4
|
|
|
4
|
|
21
|
use base 'POSIX::1003::Module'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
621
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
16
|
use Carp 'croak'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
673
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my (@ulimit, @rlimit, @constants, @functions); |
17
|
|
|
|
|
|
|
our %EXPORT_TAGS = |
18
|
|
|
|
|
|
|
( ulimit => \@ulimit |
19
|
|
|
|
|
|
|
, rlimit => \@rlimit |
20
|
|
|
|
|
|
|
, constants => \@constants |
21
|
|
|
|
|
|
|
, functions => \@functions |
22
|
|
|
|
|
|
|
, tables => [ qw/%ulimit %rlimit/ ] |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my ($ulimit, $rlimit); |
26
|
|
|
|
|
|
|
our (%ulimit, %rlimit); |
27
|
|
|
|
|
|
|
my ($rlim_saved_max, $rlim_saved_cur, $rlim_infinity); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
BEGIN { |
30
|
4
|
|
|
4
|
|
8
|
my @ufuncs = qw/ulimit ulimit_names/; |
31
|
4
|
|
|
|
|
8
|
my @rfuncs = qw/getrlimit setrlimit rlimit_names/; |
32
|
4
|
|
|
|
|
3
|
my @rconst = qw/RLIM_SAVED_MAX RLIM_SAVED_CUR RLIM_INFINITY/; |
33
|
|
|
|
|
|
|
|
34
|
4
|
|
|
|
|
53
|
$ulimit = ulimit_table; |
35
|
4
|
|
|
|
|
13
|
@ulimit = (keys %$ulimit, @ufuncs, '%ulimit'); |
36
|
4
|
|
|
|
|
16
|
tie %ulimit, 'POSIX::1003::ReadOnlyTable', $ulimit; |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
55
|
$rlimit = rlimit_table; |
39
|
4
|
|
|
|
|
21
|
@rlimit = (keys %$rlimit, @rfuncs, @rconst, '%rlimit'); |
40
|
4
|
|
|
|
|
12
|
tie %rlimit, 'POSIX::1003::ReadOnlyTable', $rlimit; |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
|
|
|
28
|
push @constants, keys %$ulimit, keys %$rlimit; |
43
|
4
|
|
|
|
|
8
|
push @functions, @ufuncs, @rfuncs; |
44
|
|
|
|
|
|
|
|
45
|
4
|
|
|
|
|
6
|
$rlim_saved_max = delete $rlimit->{RLIM_SAVED_MAX}; |
46
|
4
|
|
|
|
|
5
|
$rlim_saved_cur = delete $rlimit->{RLIM_SAVED_CUR}; |
47
|
4
|
|
|
|
|
2436
|
$rlim_infinity = delete $rlimit->{RLIM_INFINITY}; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
3
|
|
|
3
|
0
|
615
|
sub RLIM_SAVED_MAX { $rlim_saved_max } |
51
|
2
|
|
|
2
|
0
|
8
|
sub RLIM_SAVED_CUR { $rlim_saved_cur } |
52
|
3
|
|
|
3
|
0
|
10
|
sub RLIM_INFINITY { $rlim_infinity } |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub getrlimit($); |
55
|
|
|
|
|
|
|
sub setrlimit($$;$); |
56
|
|
|
|
|
|
|
sub ulimit($;$); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub exampleValue($) |
60
|
0
|
|
|
0
|
1
|
0
|
{ my ($class, $name) = @_; |
61
|
0
|
0
|
|
|
|
0
|
if($name =~ m/^RLIMIT_/) |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
62
|
0
|
|
|
|
|
0
|
{ my ($soft, $hard, $success) = getrlimit $name; |
63
|
0
|
|
0
|
|
|
0
|
$soft //= 'undef'; |
64
|
0
|
|
0
|
|
|
0
|
$hard //= 'undef'; |
65
|
0
|
|
|
|
|
0
|
return "$soft, $hard"; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
elsif($name =~ m/^UL_GET|^GET_/) |
68
|
0
|
|
|
|
|
0
|
{ my $val = ulimit $name; |
69
|
0
|
0
|
|
|
|
0
|
return defined $val ? $val : 'undef'; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
elsif($name =~ m/^UL_SET|^SET_/) |
72
|
0
|
|
|
|
|
0
|
{ return '(setter)'; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
else |
75
|
0
|
|
|
|
|
0
|
{ $class->SUPER::exampleValue($name); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub ulimit($;$) |
81
|
7
|
|
50
|
7
|
1
|
1055
|
{ my $key = shift // return; |
82
|
7
|
100
|
|
|
|
13
|
if(@_) |
83
|
1
|
50
|
|
|
|
5
|
{ $key =~ /^UL_SET|^SET_/ |
84
|
|
|
|
|
|
|
or croak "pass the constant name as string ($key)"; |
85
|
1
|
|
50
|
|
|
5
|
my $id = $ulimit->{$key} // return; |
86
|
1
|
|
|
|
|
6
|
return _ulimit($id, shift); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
else |
89
|
6
|
100
|
|
|
|
233
|
{ $key =~ /^UL_GET|^GET_/ |
90
|
|
|
|
|
|
|
or croak "pass the constant name as string ($key)"; |
91
|
4
|
|
50
|
|
|
11
|
my $id = $ulimit->{$key} // return; |
92
|
4
|
|
|
|
|
13
|
_ulimit($id, 0); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub _create_constant($) |
97
|
20
|
|
|
20
|
|
19
|
{ my ($class, $name) = @_; |
98
|
20
|
100
|
|
|
|
36
|
if($name =~ m/^RLIMIT_/) |
99
|
18
|
|
50
|
0
|
|
32
|
{ my $id = $rlimit->{$name} // return sub() {undef}; |
|
0
|
|
|
|
|
0
|
|
100
|
18
|
50
|
|
3
|
|
54
|
return sub(;$$) { @_ ? _setrlimit($id, $_[0], $_[1]) : (_getrlimit($id))[0] }; |
|
3
|
|
|
|
|
1101
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
else |
103
|
2
|
|
50
|
0
|
|
4
|
{ my $id = $ulimit->{$name} // return sub() {undef}; |
|
0
|
|
|
|
|
0
|
|
104
|
3
|
|
|
3
|
|
1171
|
return $name =~ m/^UL_GET|^GET_/ |
105
|
2
|
100
|
|
0
|
|
12
|
? sub() {_ulimit($id, 0)} : sub($) {_ulimit($id, shift)}; |
|
0
|
|
|
|
|
0
|
|
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub getrlimit($) |
111
|
21
|
|
50
|
21
|
1
|
477
|
{ my $key = shift // return; |
112
|
21
|
100
|
|
|
|
312
|
$key =~ /^RLIMIT_/ |
113
|
|
|
|
|
|
|
or croak "pass the constant name as string ($key)"; |
114
|
|
|
|
|
|
|
|
115
|
19
|
|
|
|
|
24
|
my $id = $rlimit->{$key}; |
116
|
19
|
50
|
|
|
|
63
|
defined $id ? _getrlimit($id) : (); |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub setrlimit($$;$) |
121
|
1
|
|
|
1
|
1
|
171
|
{ my ($key, $cur, $max) = @_; |
122
|
1
|
50
|
|
|
|
5
|
$key =~ /^RLIMIT_/ |
123
|
|
|
|
|
|
|
or croak "pass the constant name as string ($key)"; |
124
|
|
|
|
|
|
|
|
125
|
1
|
|
|
|
|
2
|
my $id = $rlimit->{$key}; |
126
|
1
|
|
33
|
|
|
9
|
$max //= RLIM_INFINITY; |
127
|
1
|
50
|
|
|
|
7
|
defined $id ? _setrlimit($id, $cur, $max) : (); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
1
|
|
|
1
|
1
|
247
|
sub ulimit_names() { keys %$ulimit } |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
1
|
|
|
1
|
1
|
239
|
sub rlimit_names() { keys %$rlimit } |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |