.TH ulimit() "" "" "System Call (libc)"
.PC "Get/set limits for a process"
.B "#include <ulimit.h>"
\fBlong ulimit (\fIcommand \fB[, \fIblocks^\fB])\fR
\fBint \fIcommand\^\fB, \fIblocks^\fB;\fR
.PP
The system call
.B ulimit()
retrieves or sets limits on what a process can do.
.I command
indicates what you want it to do, as follows:
.IP \fBUL_GETFSIZE\fR 0.3i
Return the maximum size, in blocks, of a file that the current
process can create.
.IP \fBUL_SETFSIZE\fR
Limit to
.I 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
.B root
can increase it.
.IP \fBUL_GMEMLIM\fR
Return the current process's break value.
For details on the break value, see the Lexicon entry for
.BR brk() .
.IP \fBUL_GDESLIM\fR
Return the maximum number of files that this process can open.
.PP
Each of the above commands is defined in the header file
.BR ulimit.h .
When called to execute the command
.BR UL_SETFSIZE ,
.B ulimit()
requires a second integer argument;
when called to execute any other command,
.B ulimit()
takes only one argument.
.PP
If all goes well,
.B ulimit()
returns a non-negative value.
.B ulimit()
fails if any of the following occur:
.IP \(bu 0.3i
A process owned by someone other than the superuser
.B root
attempted to increase its file-size limit.
.B ulimit()
returns \-1 and sets
.B errno
to
.BR EPERM .
.IP \(bu
The first argument to
.B ulimit()
was something other than one of the above-named values.
.B ulimit()
returns \-1 and sets
.B errno
to
.BR EINVAL .
.SH "See Also"
.Xr "brk()," brk()
.Xr "libc," libc
.Xr "ulimit.h" ulimit.h
.SH Notes
.B ulimit()
does not fail
.I "per se"
if you invoke it with option
.B UL_SETFSIZE
and do not supply a second argument.
However, doing so will (or should) crash the process.
.IR "Caveat utilitor" .
