Sys V fork IS broken!

Chris Torek chris at mimsy.umd.edu
Thu Aug 2 18:17:50 AEST 1990


Just for fun (well, not really :-) ), here is what the 4BSD man page says
about fork:

     [EAGAIN]	    The system-imposed limit on the total number
		    of processes under execution would be
		    exceeded.  This limit is configuration-
		    dependent.

     [EAGAIN]	    The system-imposed limit MAXUPRC
		    (<sys/param.h>) on the total number of
		    processes under execution by a single user
		    would be exceeded.

     [ENOMEM]	    There is insufficient swap space for the new
		    process.

These are the only errors listed, thus the only two that will ever
be returned (and if you believe that . . . :-) ).

Now, arguably the first two EAGAINs should be different codes:
there is a distinct difference between `We're sorry, all circuits
are busy' and `We're sorry, all your personal phones are busy'.
Indeed, if EAGAIN is to be used for both `out of system-wide
process table slots' and `too many of your own processes running',
one could argue that open should not distinguish between EMFILE
(`you personally have too many files open') and ENFILE (`everyone
put together have too many files open').

At any rate, the Berkeley fork will not fail just because the
system is temporarily short of physical memory.  (It can, however,
deadlock both in fork() and when growing a process....  Fork can
only deadlock when there is almost no real memory at all, though
[`almost none' means `USRPTSIZE + NPROC*HIGHPAGES < maxmem'].)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list