[mod.computers.68k] ! fork

jejones@mcrware.UUCP.UUCP (02/14/87)

Sure--the OS-9 F$Fork system call creates a process running a specified
module (the "primary" module you see listed in the output of "procs,"
the OS-9 analogue of "ps"), with a parameter so that you can optionally
override the default initial data memory allocation that lives in the
module header.  OS-9/6809's F$Fork gives you no choice but to let the
child inherit paths 0, 1, and 2; OS-9/68000 lets you specify the number
of paths the child should inherit (a contiguous hunk, starting with 0).

Since OS-9 also has the I$Dup system call, semantics essentially like
the Unix dup(), the shell does something like the following to redirect,
say, stdin when it spawns a child:

	n = dup(0)
	open file that child is to get stdin from
		(1st available path # is used, so it's #0)
	fork child
	close(0)
	dup(n)
		(1st available path # is used, so it's #0)
	close(n)
		(we don't need the copy any more)

with analogous stuff if stdout is redirected.  To make it work right,
you have to do the dups, opens, and closes in the right order.

		James Jones