ULIMIT(3) |
Library Functions Manual |
ULIMIT(3) |
NAME
ulimit — get and set process limits
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <ulimit.h>
long int
ulimit(int cmd, ...);
DESCRIPTION
The
ulimit() function provides a method to query or alter resource limits of the calling process. The method to be performed is specified by the
cmd argument; possible values are:
-
UL_GETFSIZE
-
Return the soft file size limit of the process. The value returned is in units of 512-byte blocks. If the result cannot be represented in an object of type long int, the result is unspecified.
-
UL_SETFSIZE
-
Set the hard and soft file size limits of the process to the value of the second argument passed, which is in units of 512-byte blocks, and which is expected to be of type long int. The new file size limit of the process is returned. Any process may decrease the limit, but raising it is only permitted if the caller is the super-user.
If successful, the ulimit() function will not change the setting of errno.
RETURN VALUES
If successful, the ulimit() function returns the value of the requested limit. Otherwise, it returns -1, sets errno to indicate an error, and the limit is not changed. Therefore, to detect an error condition applications should set errno to 0, call ulimit(), and check if -1 is returned and errno is non-zero.
ERRORS
The
ulimit() function will fail if:
-
[EINVAL]
-
The cmd argument is not valid.
-
[EPERM]
-
It was attempted to increase a limit, and the caller is not the super-user.
STANDARDS
The
ulimit() function conforms to X/Open System Interfaces and Headers Issue 5 (“XSH5”) and IEEE Std 1003.1-2001 (“POSIX.1”). It was marked as obsolete in the IEEE Std 1003.1-2008 (“POSIX.1”) revision, which recommended the use of
getrlimit(2) and
setrlimit(2) instead, noting that because
ulimit() uses the type
long rather than
rlim_t, it may not be sufficient for file sizes on many current systems.