#define _XOPEN_SOURCE
#include <ulimit.h>
long int ulimit(int cmd, …);
General description
The ulimit()
function provides control over the process file size limits. The cmd argument
controls whether the file size limits are obtained or set. The cmd argument
can be one of the following, defined in <ulimit.h>:
UL_GETFSIZE
Return the
soft (current) file size limit of the process. The limit returned
is in units of 512-byte blocks. The return value is the integer portion
of the soft file size limit divided by 512. Refer to the setrlimit()
function, RLIMIT_FSIZE resource description for more detail.
UL_SETFSIZE
Set the hard
(maximum) and soft (current) file size limits for output operations
of the process. The value of the second argument is used, and is
treated as a long int. Refer to the setrlimit() function, RLIMIT_FSIZE
resource description for more detail and restrictions on lowering
and raising file size limits. The hard and soft file size limits are
set to the specified value multiplied by 512. The new file size limit
(in 512 byte increments) is returned.
Returned value
If successful, ulimit()
returns the value of the requested limit.
If unsuccessful,
ulimit() returns -1 and sets errno to one of the following values:
Error Code
Description
EINVAL
The cmd argument is not valid.
EPERM
To increase the file size limit, superuser authority is required.