
--------[ Beating the fork() bomb ]--------

The following is not a weird smilie. It's a Bash shell program that
calls fork(2) in a loop, eventually filling up the process table and
making a system unusable without a reboot -- unless you have process
limits configured:

   :(){ :|:& };:

There are many explanations of this snippet of code on the web,
like http://www.cyberciti.biz/faq/understanding-bash-fork-bomb/
(which also links to a recipe for configuring Linux limits).

Your mission: configure your Illumos VM to survive the fork bomb,
and dtrace it doing so. Read the fork() code to see where it
is stopped. Notice that in Illumos you can limit resources per
"projects" and "tasks", not just users.


--------[ More about forks! ]--------

Note that unlike Linux Illumos' fork system call entry point is
called forksys. Understand the different kinds of fork() calls
and what they do with threads in the fork-ed process; read "man fork"
and then have a look first at libc (in userland): 

http://src.illumos.org/source/search?q=&defs=fork&refs=&path=libc&hist=&project=illumos-gate

and then in the kernel:

http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/os/fork.c#108

Follow the call with dtrace (the indenting pragma is useful) to the point
where a new process proc_t and PID are created for the forked-off child process:

http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/os/fork.c#213

and go in. Observe how procdir[] is being managed and how the new
proc_t is linked into it. Create a snapshot of procdir[] with your
script (assume that ps is getting executed; it will loop over the
procdir[]'s endtries for you---remember, you cannot write loops in D!)

In particular, observe how procentfree is used:
http://src.illumos.org/source/search?q=procentfree&path=%2Futs%2F&project=illumos-gate

Looks like it's not used for anything much at all! It's value is only
read at lines 169 and 260. What's going on? Trace the flow (manually)
through the code to understand what good it is.

--------[ Resource pools ]--------

Then observe suplication of the as structures of the forked process for
the cases of regular fork and vfork:

http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/os/fork.c#227

Skim the rest of the cfork() function to see what resources are replicated.
Pay special attention to resource pools (see the long comment at the top of pool.c)

http://src.illumos.org/source/xref/illumos-gate/usr/src/uts/common/os/pool.c#244
