ulimit()

NAME

ulimit - get and set process limits

SYNOPSIS

#include <ulimit.h>

long int ulimit(int cmd, ...);

DESCRIPTION

The ulimit(2) function provides for control over process limits. The cmd values, defined in <ulimit.h> include:

UL_GDESLIM
Return the processes current soft limit for open file descriptors.
UL_GETFSIZE
Return the soft file size limit of the process. The limit is in units of 512-byte blocks and is inherited by child processes. Files of any size can be read. The return value is the integer part of the soft file size limit divided by 512. If the result cannot be represented as a long int, the result is unspecified.
UL_SETFSIZE
Set the hard and soft file size limits for output operations of the process to the value of the second argument, taken as a long int. Any process may decrease its own hard limit, but only a process with appropriate privileges may increase the limit. The new file size limit is returned. The hard and soft file size limits are set to the specified value multiplied by 512. If the result would overflow an rlim_t, the actual value set is unspecified.

RETURN VALUE

Upon successful completion, ulimit(2) returns the value of the requested limit. Otherwise -1 is returned and errno is set to indicate the error. The ulimit(2) function will not change the setting of errno if successful.

ERRORS

The ulimit(2) function will fail and the limit will be unchanged if:

[EINVAL]
The cmd argument is not valid.
[EPERM]
A process not having appropriate privileges attempts to increase its file size limit.
[EPERM]
A process not having appropriate privileges attempts to increase its file size limit.

APPLICATION USAGE

As all return values are permissible in a successful situation, an application wishing to check for error situations should set errno to 0, then call ulimit(2), and, if it returns -1, check to see if errno is non-zero.

SEE ALSO

getrlimit(2)

setrlimit(2)

write(2)

DERIVATION

Derived from Issue 1 of the SVID.