Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bdf940d

Browse files
committed
#17409: Document RLIM_INFINITY and use it to clarify the setrlimit docs.
1 parent 3583761 commit bdf940d

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

Doc/library/resource.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ which cannot be checked or controlled by the operating system are not defined in
4343
this module for those platforms.
4444

4545

46+
.. data:: RLIM_INFINITY
47+
48+
Constant used to represent the the limit for an unlimited resource.
49+
50+
4651
.. function:: getrlimit(resource)
4752

4853
Returns a tuple ``(soft, hard)`` with the current soft and hard limits of
@@ -54,12 +59,20 @@ this module for those platforms.
5459

5560
Sets new limits of consumption of *resource*. The *limits* argument must be a
5661
tuple ``(soft, hard)`` of two integers describing the new limits. A value of
57-
``-1`` can be used to specify the maximum possible upper limit.
62+
:data:`~resource.RLIM_INFINITY` can be used to request a limit that is
63+
unlimited.
5864

5965
Raises :exc:`ValueError` if an invalid resource is specified, if the new soft
60-
limit exceeds the hard limit, or if a process tries to raise its hard limit
61-
(unless the process has an effective UID of super-user). Can also raise
62-
:exc:`error` if the underlying system call fails.
66+
limit exceeds the hard limit, or if a process tries to raise its hard limit.
67+
Specifying a limit of :data:`~resource.RLIM_INFINITY` when the hard or
68+
system limit for that resource is not unlimited will result in a
69+
:exc:`ValueError`. A process with the effective UID of super-user can
70+
request any valid limit value, including unlimited, but :exc:`ValueError`
71+
will still be raised if the requested limit exceeds the system imposed
72+
limit.
73+
74+
``setrlimit`` may also raise :exc:`error` if the underlying system call
75+
fails.
6376

6477
These symbols define resources whose consumption can be controlled using the
6578
:func:`setrlimit` and :func:`getrlimit` functions described below. The values of

0 commit comments

Comments
 (0)