Austin Group Defect Tracker

Aardvark Mark IV


Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0001418 [1003.1(2016/18)/Issue7+TC2] Shell and Utilities Comment Enhancement Request 2020-11-06 10:32 2021-03-19 09:47
Reporter geoffclare View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Applied  
Name Geoff Clare
Organization The Open Group
User Reference
Section ulimit
Page Number 3326-3327
Line Number 111991-112065
Interp Status ---
Final Accepted Text See Note: 0005254.
Summary 0001418: Add options to ulimit to match get/setrlimit()
Description Currently the ulimit utility only provides the means to query and set the RLIMIT_FSIZE soft limit. It should be able to query and set the hard limit, and also the soft and hard limits for the other resources that are specified for getrlimit() and setrlimit(). The -a option would also be useful.

The proposed additions are widely supported.
Desired Action Replace the NAME, SYNOPSIS, DESCRIPTION, OPTIONS, and OPERANDS sections on the ulimit page with:

NAME
ulimit -- report or set resource limits

SYNOPSIS
[XSI]ulimit [-H|-S] -a

ulimit [-H|-S] [-cdfnstv] [newlimit][/XSI]

DESCRIPTION
The ulimit utility shall report or set the resource limits in effect in the process in which it is executed.

Soft limits can be changed by a process to any value that is less than or equal to the hard limit. A process can (irreversibly) lower its hard limit to any value that is greater than or equal to the soft limit. Only a process with appropriate privileges can raise a hard limit.

The value unlimited for a resource shall be considered to be larger than any other limit value. When a resource has this limit value, the implementation shall not enforce limits on that resource. In locales other than the POSIX locale, ulimit may support additional non-numeric values with the same meaning as unlimited.

The behavior when resource limits are exceeded shall be as described in the System Interfaces volume of POSIX.1-202x for the setrlimit() function.

OPTIONS
The ulimit utility shall conform to [xref to XBD 12.2].

The following options shall be supported:

-H
Report hard limit(s) or set only a hard limit.
-S
Report soft limit(s) or set only a soft limit.
-a
Report the limit value for all of the resources named below and for any implementation-specific additional resources.
-c
Report, or set if the newlimit operand is present, the core image size limit(s) in units of 512 bytes. [RLIMIT_CORE]
-d
Report, or set if the newlimit operand is present, the data segment size limit(s) in units of 1024 bytes. [RLIMIT_DATA]
-f
Report, or set if the newlimit operand is present, the file size limit(s) in units of 512 bytes. [RLIMIT_FSIZE]
-n
Report, or set if the newlimit operand is present, the limit(s) on the number of open file descriptors, given as a number one greater than the maximum value that the system assigns to a newly-created descriptor. [RLIMIT_NOFILE]
-s
Report, or set if the newlimit operand is present, the stack size limit(s) in units of 1024 bytes. [RLIMIT_STACK]
-t
Report, or set if the newlimit operand is present, the per-process CPU time limit(s) in units of seconds. [RLIMIT_CPU]
-v
Report, or set if the newlimit operand is present, the address space size limit(s) in units of 1024 bytes. [RLIMIT_AS]
Where an option description is followed by [RLIMIT_name] it indicates which resource for the getrlimit() and setrlimit() functions, defined in the System Interfaces volume of POSIX.1-202x, the option corresponds to.

If neither the -H nor -S option is specified:

  • If the newlimit operand is present, it shall be used as the new value for both the hard and soft limits.

  • If the newlimit operand is not present, -S shall be the default.


If no options other than -H or -S are specified, the behavior shall be as if the -f option was (also) specified.

OPERANDS
The following operand shall be supported:

newlimit
Either an integer value to use as the new limit(s) for the specified resource, in the units specified in OPTIONS, or a non-numeric string indicating no limit, as described in the DESCRIPTION section. Numerals in the range 0 to the maximum limit value supported by the implementation for any resource shall be syntactically recognized as numeric values.

Replace the STDOUT section on the ulimit page with:
The standard output shall be used when no newlimit operand is present.

If the -a option is specified, the output written for each resource shall consist of one line that includes:

  • A short phrase identifying the resource (for example "file size").

  • An indication of the units used for the resource.

  • The ulimit option used to specify the resource.

  • The limit value.


The format used within each line is unspecified, except that the format used for the limit value shall be as described below for case where the -a option is not specified.

If the -a option is not specified:

  • If the resource being reported has a numeric limit, the limit value shall be written in the following format:
    "%1d\n", <limit value>
    where <limit value> is the value of the limit in the units specified in OPTIONS.

  • If the resource being reported does not have a numeric limit, in the POSIX locale the following format shall be used:
    "unlimited\n"

Replace the APPLICATION USAGE, EXAMPLES, and RATIONALE sections on the ulimit page with:

APPLICATION USAGE
Since ulimit affects the current shell execution environment, it is always provided as a shell regular built-in. If it is called with an operand in a separate utility execution environment, such as one of the following:
nohup ulimit -f 10000
env ulimit -S -c 10000
it does not affect the limit(s) in the caller's environment.

See also the APPLICATION USAGE for [xref to getrlimit()].

EXAMPLES
Set the hard and soft file size limits to 51200 bytes:
ulimit -f 100

Save and restore a soft resource limit (where X is an option letter specifying a resource):
saved=$(ulimit -X)

...

ulimit -X -S "$saved"

Execute a utility with a CPU limit of 5 minutes (using an asynchronous subshell to ensure the limit is set in a child process):
(ulimit -t 300; exec utility_name </dev/null) &
wait $!

RATIONALE
The ulimit utility has no equivalent of the special values RLIM_SAVED_MAX and RLIM_SAVED_CUR returned by getrlimit(), as ulimit is required to be able to output, and accept as input, all numeric limit values supported by the system.

Add XCU ulimit to the SEE ALSO section on the getrlimit() page.
Tags issue8
Attached Files

- Relationships
related to 0001669Applied Issue 8 drafts Make the ulimit utility consistent with [gs]etrlimit() wrt XSI 

-  Notes
(0005110)
geoffclare (manager)
2020-11-09 10:38
edited on: 2020-11-24 10:04

Updated proposal...

Replace the NAME, SYNOPSIS, DESCRIPTION, OPTIONS, and OPERANDS sections on the ulimit page with:

NAME
ulimit -- report or set resource limits

SYNOPSIS
[XSI]ulimit [-H|-S] -a

ulimit [-H|-S] [-cdfnstv] [newlimit][/XSI]

DESCRIPTION
The ulimit utility shall report or set the resource limits in effect in the process in which it is executed.

Soft limits can be changed by a process to any value that is less than or equal to the hard limit. A process can (irreversibly) lower its hard limit to any value that is greater than or equal to the soft limit. Only a process with appropriate privileges can raise a hard limit.

The value unlimited for a resource shall be considered to be larger than any other limit value. When a resource has this limit value, the implementation shall not enforce limits on that resource. In locales other than the POSIX locale, ulimit may support additional non-numeric values with the same meaning as unlimited.

The behavior when resource limits are exceeded shall be as described in the System Interfaces volume of POSIX.1-202x for the setrlimit() function.

OPTIONS
The ulimit utility shall conform to [xref to XBD 12.2], except that:
  • The order in which options other than -H, -S, and -a are specified may be significant.

  • Conforming applications shall specify each option separately; that is, grouping option letters (for example, -fH) need not be recognized by all implementations.

The following options shall be supported:

-H
Report hard limit(s) or set only a hard limit.
-S
Report soft limit(s) or set only a soft limit.
-a
Report the limit value for all of the resources named below and for any implementation-specific additional resources.
-c
Report, or set if the newlimit operand is present, the core image size limit(s) in units of 512 bytes. [RLIMIT_CORE]
-d
Report, or set if the newlimit operand is present, the data segment size limit(s) in units of 1024 bytes. [RLIMIT_DATA]
-f
Report, or set if the newlimit operand is present, the file size limit(s) in units of 512 bytes. [RLIMIT_FSIZE]
-n
Report, or set if the newlimit operand is present, the limit(s) on the number of open file descriptors, given as a number one greater than the maximum value that the system assigns to a newly-created descriptor. [RLIMIT_NOFILE]
-s
Report, or set if the newlimit operand is present, the stack size limit(s) in units of 1024 bytes. [RLIMIT_STACK]
-t
Report, or set if the newlimit operand is present, the per-process CPU time limit(s) in units of seconds. [RLIMIT_CPU]
-v
Report, or set if the newlimit operand is present, the address space size limit(s) in units of 1024 bytes. [RLIMIT_AS]
Where an option description is followed by [RLIMIT_name] it indicates which resource for the getrlimit() and setrlimit() functions, defined in the System Interfaces volume of POSIX.1-202x, the option corresponds to.

If neither the -H nor -S option is specified:

  • If the newlimit operand is present, it shall be used as the new value for both the hard and soft limits.

  • If the newlimit operand is not present, -S shall be the default.

If no options other than -H, -S, or -a are specified, the behavior shall be as if the -f option was (also) specified.

If the newlimit operand is present and more than one option other than -H or -S is specified, the behavior is unspecified.

If any option other than -H or -S is repeated, the behavior is unspecified.

OPERANDS
The following operand shall be supported:

newlimit
Either an integer value to use as the new limit(s) for the specified resource, in the units specified in OPTIONS, or a non-numeric string indicating no limit, as described in the DESCRIPTION section. Numerals in the range 0 to the maximum limit value supported by the implementation for any resource shall be syntactically recognized as numeric values.

Replace the STDOUT section on the ulimit page with:
The standard output shall be used when no newlimit operand is present.

If the -a option is specified, or the -a option is not specified and more than one option other than -H or -S is specified, the output written for each resource shall consist of one line that includes:

  • A short phrase identifying the resource (for example "file size").

  • An indication of the units used for the resource, if the corresponding option description in OPTIONS specifies the units to be used.

  • The ulimit option used to specify the resource.

  • The limit value.

The format used within each line is unspecified, except that the format used for the limit value shall be as described below for the case where a single limit value is written. If -a is not specified and output is written for more than one resource, it is unspecified whether the lines are written in the order that the corresponding options were specified or in the order that the lines would be written for the -a option.

If a single limit value is to be written; that is, the -a option is not specified and at most one option other than -H or -S is specified:

  • If the resource being reported has a numeric limit, the limit value shall be written in the following format:
    "%1d\n", <limit value>
    where <limit value> is the value of the limit in the units specified in OPTIONS.

  • If the resource being reported does not have a numeric limit, in the POSIX locale the following format shall be used:
    "unlimited\n"

Replace the APPLICATION USAGE, EXAMPLES, and RATIONALE sections on the ulimit page with:

APPLICATION USAGE
Since ulimit affects the current shell execution environment, it is always provided as a shell regular built-in. If it is called with an operand in a separate utility execution environment, such as one of the following:
nohup ulimit -f 10000
env ulimit -S -c 10000
it does not affect the limit(s) in the caller's environment.

See also the APPLICATION USAGE for [xref to getrlimit()].

EXAMPLES
Set the hard and soft file size limits to 51200 bytes:
ulimit -f 100

Report the hard limits for file size and core image size (in the verbose format used for -a):
ulimit -H -f -c

Save and restore a soft resource limit (where X is an option letter specifying a resource):
saved=$(ulimit -X)

...

ulimit -X -S "$saved"

Execute a utility with a CPU limit of 5 minutes (using an asynchronous subshell to ensure the limit is set in a child process):
(ulimit -t 300; exec utility_name </dev/null) &
wait $!

RATIONALE
The ulimit utility has no equivalent of the special values RLIM_SAVED_MAX and RLIM_SAVED_CUR returned by getrlimit(), as ulimit is required to be able to output, and accept as input, all numeric limit values supported by the system.

Add XCU ulimit to the SEE ALSO section on the getrlimit() page.

(0005121)
geoffclare (manager)
2020-11-24 10:09
edited on: 2020-11-24 10:13

Following discussions on the mailing list, I have updated Note: 0005110 as follows:

* Applications are required to specify each option separately (as for c99).

* Unspecified behaviour if a resource-selection option is repeated.

* Output lines only need to include the units where the corresponding option description specifies the units to be used.

One issue that remains is whether to keep the current requirement for multiple resource-selection options with no newlimit operand or to make the behaviour unspecified. This needs to be decided in a teleconference.

(0005254)
geoffclare (manager)
2021-03-01 16:41
edited on: 2021-03-04 16:17

Replace the NAME, SYNOPSIS, DESCRIPTION, OPTIONS, and OPERANDS sections on the ulimit page with:

NAME
ulimit -- report or set resource limits

SYNOPSIS
[XSI]ulimit [-H|-S] -a

ulimit [-H|-S] [-c|-d|-f|-n|-s|-t|-v] [newlimit][/XSI]

DESCRIPTION
The ulimit utility shall report or set the resource limits in effect in the process in which it is executed.

Soft limits can be changed by a process to any value that is less than or equal to the hard limit. A process can (irreversibly) lower its hard limit to any value that is greater than or equal to the soft limit. Only a process with appropriate privileges can raise a hard limit.

The value unlimited for a resource shall be considered to be larger than any other limit value. When a resource has this limit value, the implementation shall not enforce limits on that resource. In locales other than the POSIX locale, ulimit may support additional non-numeric values with the same meaning as unlimited.

The behavior when resource limits are exceeded shall be as described in the System Interfaces volume of POSIX.1-202x for the setrlimit() function.

OPTIONS
The ulimit utility shall conform to [xref to XBD 12.2], except that:
  • The order in which options other than -H, -S, and -a are specified may be significant.

  • Conforming applications shall specify each option separately; that is, grouping option letters (for example, -fH) need not be recognized by all implementations.

The following options shall be supported:

-H
Report hard limit(s) or set only a hard limit.
-S
Report soft limit(s) or set only a soft limit.
-a
Report the limit value for all of the resources named below and for any implementation-specific additional resources.
-c
Report, or set if the newlimit operand is present, the core image size limit(s) in units of 512 bytes. [RLIMIT_CORE]
-d
Report, or set if the newlimit operand is present, the data segment size limit(s) in units of 1024 bytes. [RLIMIT_DATA]
-f
Report, or set if the newlimit operand is present, the file size limit(s) in units of 512 bytes. [RLIMIT_FSIZE]
-n
Report, or set if the newlimit operand is present, the limit(s) on the number of open file descriptors, given as a number one greater than the maximum value that the system assigns to a newly-created descriptor. [RLIMIT_NOFILE]
-s
Report, or set if the newlimit operand is present, the stack size limit(s) in units of 1024 bytes. [RLIMIT_STACK]
-t
Report, or set if the newlimit operand is present, the per-process CPU time limit(s) in units of seconds. [RLIMIT_CPU]
-v
Report, or set if the newlimit operand is present, the address space size limit(s) in units of 1024 bytes. [RLIMIT_AS]
Where an option description is followed by [RLIMIT_name] it indicates which resource for the getrlimit() and setrlimit() functions, defined in the System Interfaces volume of POSIX.1-202x, the option corresponds to.

If neither the -H nor -S option is specified:

  • If the newlimit operand is present, it shall be used as the new value for both the hard and soft limits.

  • If the newlimit operand is not present, -S shall be the default.

If no options other than -H or -S are specified, the behavior shall be as if the -f option was (also) specified.

If any option other than -H or -S is repeated, the behavior is unspecified.

OPERANDS
The following operand shall be supported:

newlimit
Either an integer value to use as the new limit(s) for the specified resource, in the units specified in OPTIONS, or a non-numeric string indicating no limit, as described in the DESCRIPTION section. Numerals in the range 0 to the maximum limit value supported by the implementation for any resource shall be syntactically recognized as numeric values.

Replace the STDOUT section on the ulimit page with:
The standard output shall be used when no newlimit operand is present.

If the -a option is specified, the output written for each resource shall consist of one line that includes:

  • A short phrase identifying the resource (for example "file size").

  • An indication of the units used for the resource, if the corresponding option description in OPTIONS specifies the units to be used.

  • The ulimit option used to specify the resource.

  • The limit value.

The format used within each line is unspecified, except that the format used for the limit value shall be as described below for the case where a single limit value is written.

If a single limit value is to be written; that is, the -a option is not specified and at most one option other than -H or -S is specified:

  • If the resource being reported has a numeric limit, the limit value shall be written in the following format:
    "%1d\n", <limit value>
    where <limit value> is the value of the limit in the units specified in OPTIONS.

  • If the resource being reported does not have a numeric limit, in the POSIX locale the following format shall be used:
    "unlimited\n"

Replace the APPLICATION USAGE, EXAMPLES, and RATIONALE sections on the ulimit page with:

APPLICATION USAGE
Since ulimit affects the current shell execution environment, it is always provided as a shell regular built-in. If it is called with an operand in a separate utility execution environment, such as one of the following:
nohup ulimit -f 10000
env ulimit -S -c 10000
it does not affect the limit(s) in the caller's environment.

See also the APPLICATION USAGE for [xref to getrlimit()].

EXAMPLES
Set the hard and soft file size limits to 51200 bytes:
ulimit -f 100

Save and restore a soft resource limit (where X is an option letter specifying a resource):
saved=$(ulimit -X)

...

ulimit -X -S "$saved"

Execute a utility with a CPU limit of 5 minutes (using an asynchronous subshell to ensure the limit is set in a child process):
(ulimit -t 300; exec utility_name </dev/null) &
wait $!

RATIONALE
The ulimit utility has no equivalent of the special values RLIM_SAVED_MAX and RLIM_SAVED_CUR returned by getrlimit(), as ulimit is required to be able to output, and accept as input, all numeric limit values supported by the system.

Implementations differ in their behavior when the -a option is not specified and more than one option other than -H or -S is specified. Some write output for all of the specified resources in the same format as for -a; others write only the value for the last specified option. Both behaviors are allowed by the standard, since the SYNOPSIS lists the options as mutually exclusive.

Add XCU ulimit to the SEE ALSO section on the getrlimit() page.

(0005255)
Don Cragun (manager)
2021-03-04 16:24

Note: 0005254 was updated to change:
If no options other than -H, -S, or -a are specified, the behavior shall be as if the -f option was (also) specified.
to:
If no options other than -H or -S are specified, the behavior shall be as if the -f option was (also) specified.
(0005286)
geoffclare (manager)
2021-03-19 09:47

When applying this bug I encountered a minor conflict with bug 0000854, which adds a new first paragraph to the ulimit APPLICATION USAGE. I kept that new paragraph and replaced the rest of APPLICATION USAGE with the content from Note: 0005254.

- Issue History
Date Modified Username Field Change
2020-11-06 10:32 geoffclare New Issue
2020-11-06 10:32 geoffclare Name => Geoff Clare
2020-11-06 10:32 geoffclare Organization => The Open Group
2020-11-06 10:32 geoffclare Section => ulimit
2020-11-06 10:32 geoffclare Page Number => 3326-3327
2020-11-06 10:32 geoffclare Line Number => 111991-112065
2020-11-06 10:32 geoffclare Interp Status => ---
2020-11-09 10:38 geoffclare Note Added: 0005110
2020-11-09 10:44 geoffclare Note Edited: 0005110
2020-11-09 10:49 geoffclare Note Edited: 0005110
2020-11-24 10:03 geoffclare Note Edited: 0005110
2020-11-24 10:04 geoffclare Note Edited: 0005110
2020-11-24 10:09 geoffclare Note Added: 0005121
2020-11-24 10:13 geoffclare Note Edited: 0005121
2021-03-01 16:41 geoffclare Note Added: 0005254
2021-03-01 16:44 Don Cragun Final Accepted Text => See Note: 0005254.
2021-03-01 16:44 Don Cragun Status New => Resolved
2021-03-01 16:44 Don Cragun Resolution Open => Accepted As Marked
2021-03-01 16:45 Don Cragun Tag Attached: issue8
2021-03-04 16:16 geoffclare Note Edited: 0005254
2021-03-04 16:17 geoffclare Note Edited: 0005254
2021-03-04 16:24 Don Cragun Note Added: 0005255
2021-03-19 09:47 geoffclare Note Added: 0005286
2021-03-19 09:47 geoffclare Status Resolved => Applied
2023-04-17 14:23 geoffclare Relationship added related to 0001669


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker