typedef void (*Spawnf)(char*, char*);
void spawn(char* arg0, char* args, int dup, Spawnf f, char* a)
void tspawn(void (*f)(void*), void *a, char* sel)
void die(char* reason)
Dup is a set of bits used to
control how virtual memory, name space, and program are initialized:
DPROG when set, causes the program arg0 to be copied (not linked) to the new process program box. Even when DPROC is not set, the program will be copied if the link operation fails—to allow callers to try link(2) and still get the process created when the program does not share the machine with the processor. DVM when set, causes the /b/proc/me/vm virtual memory box to be copied (not linked) to the new process.
DNS when set, causes the /b/proc/me/ns name space to be copied (not linked) to the process.
If the parameter f is nil, a is considered to be the name for a box to link to the process legacy; it may be nil. Otherwise, f is a function to be called before copying/linking the program, and a is an argument to be
Tspawn is another convenience function used to create a process that shares the virtual memory with the caller (i.e. what other systems would call a kernel thread). The user must supply the startint address for the thread, f, and its initial argument. Before returning to the caller, tspawn copies to sel the name of the box for the process just started, in case sel was not nil.
Die is a convenience function that terminates process execution. The string given is copied to the process legacy box.
The second call to
spawn creates a process using the same I/O devices in use by the caller process. Here, the new process legacy box gets linked to a channel, so that the copy(2) call would both block until the new process terminates and copy the process legacy to the stardard output device.