Design for 'Fork'
Michael Elizabeth Chastain
<mec@duracef.shout.net>
Sat 18 Nov 1995

Copyright 1995 Michael Chastain
Licensed under the Gnu Public License, Version 2



Part of this was easy: the parent gets a return value, and I replay it.
When the parent reads a pipe or calls 'wait4', I replay that.  *No
actual child is needed.*

But 'fork' takes no arguments, so it's difficult to annul.  I use
'setrlimit' on 'RLIMIT_NPROC' to 0.  This works for all users except
root.  This is why root can't replay.

In release 0.2 I had a hairy scheme for capturing the child without
races, killing the parent, and substituting the child.  (It was
necessary to avoid killing the child because of unpreventable SIGCHLD).
This scheme had the side effect of changing the target pid, which would
interfere with viewer processes reading '/proc/$pid/mem'.  So it's gone.

The controller needs to control a whole tree of processes.  When a
controlled process which is not replaying forks, the controller writes a
'jump .' into the instruction space of the controlled process at the
return address from the 'fork' system call.  When the child is created,
it will loop on this instruction until the controller attaches it.
