ulimit()" -- System Call (libc)" "

Get/set limits for a process

#include <ulimit.h>
lloonngg uulliimmiitt ((_c_o_m_m_a_n_d [[,, _b_l_o_c_k_s_^]]))
iinntt _c_o_m_m_a_n_d,, _b_l_o_c_k_s_^;;

The system call ulimit() retrieves or sets limits on what a process can do. command indicates what you want it to do, as follows:

UULL__GGEETTFFSSIIZZEE
Return the maximum size, in blocks, of a file that the current process can create.

UULL__SSEETTFFSSIIZZEE
Limit to blocks the size of any regular file that any process can create. A process may decrease this limit, but only a process owned by the superuser root can increase it.

UULL__GGMMEEMMLLIIMM
Return the current process's break value. For details on the break value, see the Lexicon entry for brk().

UULL__GGDDEESSLLIIMM
Return the maximum number of files that this process can open.

Each of the above commands is defined in the header file ulimit.h. When called to execute the command UL_SETFSIZE, ulimit() requires a second integer argument; when called to execute any other command, ulimit() takes only one argument.

If all goes well, ulimit() returns a non- negative value. ulimit() fails if any of the following occur:

+o
A process owned by someone other than the superuser root attempted to increase its file-size limit. ulimit() returns -1 and sets errno to EPERM.

+o
The first argument to ulimit() was something other than one of the above-named values. ulimit() returns -1 and sets errno to EINVAL.

See Also

Notes

ulimit() does not fail per se if you invoke it with option UL_SETFSIZE and do not supply a second argument. However, doing so will (or should) crash the process. Caveat utilitor.