Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

222 Process Environment Chapter 7


RLIMIT_RSS Maximum resident set size (RSS) in bytes. If available
physical memory is low,the kernel takes memory from
processes that exceed their RSS.
RLIMIT_SBSIZE The maximum size in bytes of socket buffers that a user can
consume at any given time.
RLIMIT_SIGPENDING The maximum number of signals that can be queued for a
process. This limit is enforced by thesigqueue function
(Section 10.20).
RLIMIT_STACK The maximum size in bytes of the stack. See Figure7.6.
RLIMIT_SWAP The maximum amount of swap space in bytes that a user can
consume.
RLIMIT_VMEM This is a synonym forRLIMIT_AS.

FreeBSD Linux Mac OS X Solaris
Limit XSI 8.0 3.2.0 10.6.8 10

RLIMIT_AS ••• •
RLIMIT_CORE •••••
RLIMIT_CPU •••••
RLIMIT_DATA •••••
RLIMIT_FSIZE •••••
RLIMIT_MEMLOCK •••
RLIMIT_MSGQUEUE •
RLIMIT_NICE •
RLIMIT_NOFILE •••••
RLIMIT_NPROC •••
RLIMIT_NPTS •
RLIMIT_RSS •••
RLIMIT_SBSIZE •
RLIMIT_SIGPENDING •
RLIMIT_STACK •••••
RLIMIT_SWAP •
RLIMIT_VMEM •

Figure 7.15 Support for resource limits

The resource limits affect the calling process and areinherited by any of its children.
This means that the setting of resource limits needs to be built into the shells to affect all
our futureprocesses. Indeed, the Bourne shell, the GNU Bourne-again shell, and the
Korn shell have the built-inulimitcommand, and the C shell has the built-inlimit
command. (Theumaskandchdirfunctions also have to be handled as shell built-ins.)

Example


The program in Figure7.16 prints out the current soft limit and hardlimit for all the
resource limits supported on the system. To compile this program on all the various
Free download pdf