implement Pid;
include "sys.m";
sys: Sys;
include "draw.m";
Pid: module {
init: fn (ctxt: ref Draw->Context, argv: list of string);
};
init (nil: ref Draw->Context, argv: list of string)
{
sys = load Sys Sys->PATH;
sys->print("Pid test program started...\n");
pidc := chan of int;
spawn child(pidc);
pid := sys->pctl(0, nil);
sys->print("Parent: My pid is [%d]\n", pid);
chpid := <- pidc;
sys->print("Parent: Child pid is [%d]\n", chpid);
}
child(pidc: chan of int)
{
pid := sys->pctl(0, nil);
sys->print("Child: My pid is [%d]\n", pid);
pidc <-= pid;
exit;
}
|