Sets and gets user limits.
Standard C Library (libc.a)
The syntax for the ulimit subroutine when the Command parameter specifies a value of GET_FSIZE or SET_FSIZE is:
long int ulimit (Command, NewLimit) int Command; off_t NewLimit;
The syntax for the ulimit subroutine when the Command parameter specifies a value of GET_DATALIM, SET_DATALIM, GET_STACKLIM, SET_STACKLIM, GET_REALDIR, or SET_REALDIR is:
long int ulimit (Command, NewLimit) int Command; int NewLimit;
The ulimit subroutine controls process limits.
Even with remote files, the ulimit subroutine values of the process on the client node are used.
Note: Raising the data ulimit does not necessarily raise the program break value. If the proper memory segments are not initialized at program load time, raising your memory limit will not allow access to this memory. Also, without these memory segments initialized, the value returned after such a change may not be the proper break value. If your data limit is RLIM_INFINITY, this value will never advance past the segment size, even if that data is available. Use the -bmaxdata flag of the ld command to set up these segments at load time.
|Command|| Specifies the form of control. The following Command parameter values require that the NewLimit parameter be declared as an off_t structure:
|NewLimit||Specifies the new limit. The value and data type or structure of the NewLimit parameter depends on the Command parameter value that is used.|
To increase the size of the stack by 4096 bytes (use 4096 or PAGESIZE ), and set the rc to the new lowest valid stack address, enter:
rc = ulimit(SET_STACKLIM, ulimit(GET_STACKLIM, 0) - 4096);
Upon successful completion, the value of the requested limit is returned. Otherwise, a value of -1 is returned and the errno global variable is set to indicate the error.
All return values are permissible if the ulimit subroutine is successful. To check for error situations, an application should set the errno global variable to 0 before calling the ulimit subroutine. If the ulimit subroutine returns a value of -1, the application should check the errno global variable to verify that it is nonzero.
The ulimit subroutine is unsuccessful and the limit remains unchanged if one of the following is true:
|EPERM||A process without root user authority attempts to increase the file size limit.|
|EINVAL||The Command parameter is a value other than GET_FSIZE, SET_FSIZE, GET_DATALIM, SET_DATALIM, GET_STACKLIM, SET_STACKLIM, GET_REALDIR, or SET_REALDIR.|
This subroutine is part of Base Operating System (BOS) Runtime.
The brk subroutine, sbrk subroutine, getrlimit or setrlimit subroutine, pathconf subroutine, read subroutines, vlimit subroutine, write subroutine.