Advanced Programming in the UNIX® Environment

(lily) #1
ptg10805159

Section 7.12 Summary 225


Running this program under FreeBSD gives us the following output:
$./a.out
RLIMIT_AS (infinite) (infinite)
RLIMIT_CORE (infinite) (infinite)
RLIMIT_CPU (infinite) (infinite)
RLIMIT_DATA 536870912 536870912
RLIMIT_FSIZE (infinite) (infinite)
RLIMIT_MEMLOCK (infinite) (infinite)
RLIMIT_NOFILE 3520 3520
RLIMIT_NPROC 1760 1760
RLIMIT_NPTS (infinite) (infinite)
RLIMIT_RSS (infinite) (infinite)
RLIMIT_SBSIZE (infinite) (infinite)
RLIMIT_STACK 67108864 67108864
RLIMIT_SWAP (infinite) (infinite)
RLIMIT_VMEM (infinite) (infinite)

Solaris gives us the following results:
$./a.out
RLIMIT_AS (infinite) (infinite)
RLIMIT_CORE (infinite) (infinite)
RLIMIT_CPU (infinite) (infinite)
RLIMIT_DATA (infinite) (infinite)
RLIMIT_FSIZE (infinite) (infinite)
RLIMIT_NOFILE 256 65536
RLIMIT_STACK 8388608 (infinite)
RLIMIT_VMEM (infinite) (infinite)

Exercise 10.11continues the discussion of resource limits, after we’ve covered signals.

7.12 Summary


Understanding the environment of a C program within a UNIX system’s environment is
aprerequisite to understanding the process control features of the UNIX System. In this
chapter,we’ve looked at how a process is started, how it can terminate, and how it’s
passed an argument list and an environment. Although both the argument list and the
environment areuninterpreted by the kernel, it is the kernel that passes both from the
caller ofexecto the new process.
We’ve also examined the typical memory layout of a C program and seen how a
process can dynamically allocate and free memory.It is worthwhile to look in detail at
the functions available for manipulating the environment, since they involve memory
allocation. The functionssetjmpandlongjmpwerepresented, providing a way to
perform nonlocal branching within a process. Wefinished the chapter by describing the
resource limits that various implementations provide.
Free download pdf