mon
mon

Reputation: 22234

What is the unit of getrlimit?

Please help understand what is the unit of the getrlimit. I suppose it is byte but still it is a huge value.

>>> import resource
>>> soft, hard = resource.getrlimit(resource.RLIMIT_AS)
>>> soft
9223372036854775807
>>> hard
9223372036854775807

Upvotes: 1

Views: 469

Answers (1)

Sunil Bojanapally
Sunil Bojanapally

Reputation: 12658

rlim_t is typically of type unsigned integer, and max/unlimited address space would be (2^64) - 1 on a 64 bit machine but however you see max limits as 9223372036854775807 on your machine. On CentOS/Ubuntu machines I see RLIM_INFINITY is set to -1 and on MacOS it set 9223372036854775807 as constant representing unlimited limits.

resource.RLIM_INFINITY : Constant used to represent the limit for an unlimited resource.

On CentOS machine:

[root ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
[root ~]# ulimit -a | grep virtual
virtual memory          (kbytes, -v) unlimited
[root ~]# python
Python 2.7.5 (default, Oct 30 2018, 23:45:53)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import resource
>>> resource.RLIM_INFINITY
-1
>>> soft, hard = resource.getrlimit(resource.RLIMIT_AS)
>>> soft
-1
>>> hard
-1
>>>

Upvotes: 2

Related Questions