ulimit
Purpose
Sets and gets user limits.
Syntax
#include <sys/types.h>
off_t ulimit (cmd, newlimit)
int cmd;
off_t newlimit;
Description
The ulimit system call controls process limits. The cmd
parameter values are:
1 Returns the process's file size limit. The limit
is in units of 512-byte blocks and is inherited by
child processes. Files of any size can be read.
2 Sets the process's file size limit to the value of
the newlimit parameter. Any process can decrease
this limit, but only a process with an effective
user ID of superuser can increase the limit.
3 Returns the maximum possible break value (see
"brk, sbrk").
1004 Sets the maximum possible break value (see "brk,
sbrk"). Returns the new maximum break value,
which is newlimit rounded up to the nearest page
boundary.
1005 Returns the lowest valid stack address. (Note
that stacks grow from high addresses to low
addresses.)
1006 Sets the lowest valid stack address. Returns the
new minimum valid stack address, which is newlimit
rounded down to the nearest page boundary.
With remote files, the ulimit values of the client, or
local, node are used.
Return Value
Upon successful completion, a nonnegative value is
returned. If the ulimit system call fails, a value of -1
is returned and errno is set to indicate the error.
Diagnostics
The ulimit system call fails and the limit remains
unchanged if:
EPERM A process with an effective user ID other than
superuser attempts to increase the file size
limit.
EINVAL The cmd parameter is a value other than 1, 2,
or 3.
Example
To increase the size of the stack segment by 2048 bytes,
and set "rc" to the new lowest valid stack address:
rc = ulimit(1006, ulimit(1005, 0) - 2048);
Related Information
In this book: "brk, sbrk" and "write, writex."